随笔分类 - 排序
摘要:快速排序的思想很简单,就是每次确定一个mid位置,让该位置的数在整个数组中保持有序之后,再对其两边的子数组分别进行快速排序。 因此如何将一个选定的数变为全局有序变成了快速排序的关键问题。 提供一种思路:这种思路采用的是覆盖替换的方式,具体的,我们把pivot位置的元素存起来,准备放到一个位置。我们使
阅读全文
摘要:1095 Cars on Campus (30分) Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers
阅读全文
摘要:1098 Insertion or Heap Sort (25分) According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted o
阅读全文
摘要:记录一下自己理解的堆和堆排序吧。 堆是一种类似于完全二叉树的树形结构,对于二叉树中所有非叶子节点,如果根节点的值严格大于其两个儿子的值,则称为 大顶堆,反之称为小顶堆。 堆排序的一般步骤: 首先利用已有的数据构造一个堆,大顶堆增序,小顶堆降序。 将堆顶的元素与堆末元素交换,接着重新调整剩下的元素为一
阅读全文
摘要:1089 Insert or Merge (25分) According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted output l
阅读全文
摘要:1080 Graduate Admission (30分) It is said that in 2011, there are about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Prov
阅读全文
摘要:1055 The World's Richest (25分) Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest peo
阅读全文