数据结构
Data Structures & Algorithms · 20 notes
- 2.1 arrayhistorical
A dynamic array tracks its length and capacity on top of a fixed-size array, expanding when space runs out. The notes include its structure, API, and implementation.
- 2.2 hashmaphistorical
A map associates keys with values. These notes compare search-tree and hash-table implementations, including hashing, collision handling, and resizing.
- 2.3 linkedlisthistorical
Arrays support indexed access, while linked lists insert and remove elements by changing links. These notes implement singly and doubly linked lists with APIs and test examples.
- 2.4 queuehistorical
A queue stores and retrieves elements in first-in, first-out order. These notes cover ordinary and circular queues with their structures, APIs, and implementations.
- 2.5 sethistorical
A set stores distinct elements. These notes implement a set using a hash map, with its data structure, API, and test examples.
- 2.6 stackhistorical
A stack retrieves elements in last-in, first-out order and can be implemented with a dynamic array or linked list. The notes include its API, implementation, and test examples.
- 2.7 treehistorical
Each binary-tree node has at most two children. These notes introduce common operations through preorder, inorder, postorder, and level-order traversal.
- 2.8 Red-Black Treehistorical
A red-black tree is a balanced binary search tree that maintains balance through node colors and structural rules. These notes introduce its five properties.
- 2.9 Skip Listhistorical
A skip list adds multiple levels of index links to a linked list, trading extra space for faster search. The bottom level holds all elements, while higher levels narrow the search.
- 2.10 heaphistorical
A heap is logically a tree that can be stored in an array. Max-heaps and min-heaps maintain order through parent-child value relationships.
- 2.11 BitMaphistorical
A bitmap records whether values exist using individual bits: 1 indicates presence and 0 indicates absence.
- 2.12 BloomFilterhistorical
BloomFilter: A website has 2 billion URLs in a blacklist. How should this blacklist be stored? If a URL is entered, how can we quickly determine whether it is in this blacklist, while keeping within a given memory limit such as 500 MB?
- 2.13 graphhistorical
A graph consists of vertices and edges. It may be directed or undirected, weighted or unweighted, and represented with an adjacency matrix or adjacency list.
- 2.14 UnionFindhistorical
Union-find represents connectivity with parent-linked trees. These notes work through Quick Find, Quick Union, and their optimizations.
- 2.15 LSMhistorical
An LSM tree, or log-structured merge-tree, serves write-heavy workloads by organizing and merging data around sequential disk writes.
- 2.16 ziplisthistorical
Ziplist is a compact data structure used inside Redis. These notes record its relationship to data types such as lists and sorted sets.
- 2.17 B Treehistorical
A B-tree is a balanced multiway search tree. These notes explain its structure and use cases through exact-match and range-query requirements.
- 2.18 Sparse Indexhistorical
A sparse index stores entries for only some keys, using less space than a dense index. These notes compare their structures, lookup methods, and usage conditions.
- 2.19 Indexhistorical
An index associates search keys with data records to speed up lookups. These notes compare sparse and dense indexes, as well as forward and inverted indexes.
- 2.20 Inverted Indexhistorical
A forward index maps document IDs to documents, while an inverted index maps terms to document IDs to find documents containing a given term.