Data Structure Code Examples
These are some data structures, with a simple test environment,
that are based on my book.
Chapter 1
- An array-based stack.
- A list-based stack.
- A block-list-based stack.
- An array-based queue.
- A list-based queue.
- A cyclic list-based queue.
- A doubly linked list-based queue.
- The free list code.
- An array-based stack with shadow copy.
Chapter 2
-
A trivial search tree, without rebalancing.
-
A top-down optimal search tree.
-
A bottom-up optimal search tree.
Chapter 3
-
A height-balanced search tree.
-
A weight-balanced search tree.
-
An (a,b)-tree.
-
A red-black search tree.
-
A red-black tree with top-down rebalancing.
-
A splay tree.
-
A skip list.
Chapter 4
-
An interval tree.
-
A segment tree.
-
A weighted sum of intervals tree.
-
A weighted sum of intervals tree that supports interval-maximum queries.
-
An orthogonal range tree.
Chapter 5
-
A search tree used as heap.
-
An array-based heap.
-
A leftist heap.
-
A skew heap.
-
A binomial heap.
-
A Fibonacci heap.
-
A Minqueue.
Chapter 6
-
An amortized optimal union-find structure.
-
A worst-case optimal union-find structure.
-
A lca-find structure.
Chapter 8
-
A Trie with array nodes.
-
A Trie with list nodes.
-
A Trie with alphabet reduction.
Chapter 9
-
A hash table for integers with a universal hash function.
-
A hash table for strings with a universal hash function.
-
A perfect hash table for integers.