Data Structures & Algorithms
237 notes
Some notes are currently available only in Chinese. English translations are shown when available.
- 3.6 Backtrackinghistorical
Backtracking explores a choice, continues while it remains viable, and returns to try alternatives when it fails. These notes illustrate it with problems such as eight queens.
- 3.7 DFShistorical
Depth-first search is commonly used for string, array, and tree problems, often together with backtracking. These notes explore it through permutation and combination examples.
- 3.8 Binary Searchhistorical
Binary search compares a target with the middle element of a sorted array, then continues in the left or right half to narrow the search.
- 3.9 Bubble Sorthistorical
Bubble sort repeatedly scans an array, comparing adjacent elements and swapping out-of-order pairs until the array is sorted.
- 3.10 Linear Searchhistorical
Linear search compares array elements one by one, returning the target's index or -1 if it is absent. The notes include a Go implementation and test examples.
- 3.11 Heap Sorthistorical
Heap sort builds a heap and repeatedly removes the root while restoring the heap structure. The notes include implementation, tests, and complexity analysis.
- Next Permutationhistorical
Implement a function that obtains the next permutation. The algorithm must rearrange the given sequence of numbers into the next lexicographically greater permutation.
- 3.12 Merge Sorthistorical
Merge sort repeatedly divides an array until each part is sorted, then merges the sorted parts to produce the final array.
- 3.13 Insertion Sorthistorical
Insertion sort divides an array into sorted and unsorted parts, taking one element at a time and inserting it into the appropriate position in the sorted part.