Heap Sort 堆排序

1. 堆的定义

In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: In a max heap, for any given node C, if P is a parent node of C, then the key (the value) of P is greater than or equal to the key of C. In a min heap, the key of P is less than or equal to the key of C.


Kesa...大约 3 分钟algorithm
动态规划空间复杂度优化总结

使用动态规划解决问题时, 若使用从下至上的迭代法, 可能需要使用二维数组来缓存计算结果.

二维数组的空间复杂度为 O(n2)O(n^2), 那么需要优化缓存的大小以提高效率.


Kesa...大约 6 分钟algorithm
Quick Sort 快速排序

1. Quick Sort

Quicksort is a divide-and-conquer algorithm. It works by selecting a 'pivot' element from the array and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot. For this reason, it is sometimes called partition-exchange sort.


Kesa...大约 5 分钟algorithm
Merge Sort 归并排序

In computer science, merge sort (also commonly spelled as mergesort) is an efficient, general-purpose, and comparison-based sorting algorithm.

Conceptually, a merge sort works as follows:

  1. Divide the unsorted list into n sublists, each containing one element (a list of one element is considered sorted).
  2. Repeatedly merge sublists to produce new sorted sublists until there is only one sublist remaining. This will be the sorted list.

Kesa...大约 2 分钟algorithm