• dictionary operations - insert, delete, search
  • dynamic set operations - dictionary operations (insert, delete, search), minimun, maximum, successor, predecessor

Linked list

desc
list-insert(L,x)insert x onto the front of the linked list
list-delete(L,x)delete element x from the linked list
list-search(L,k)returning a pointer to the first element with key k

Direct-address tables

operation
direct-address-insert(T,k)
direct-address-delete(T,x)
direct-address-search(T,x)

Hash Tables

Hash function

Collision resolution

Chaining

AverageWorst
space
chained-hash-insert(T,x)
chained-hash-search(T,k)
chained-hash-delete(T,x)

Open addressing

  • Linear probing
  • Quadratic probing
  • Double hashing

Heap

  • AKA: Binary Heap
  • Type of: Nearly Complete Binary Tree (by CRLS)
  • max heap property: for every node other than the root,

Theorems:

  • The index of the -greatest () element in max-heap is ^[the same for -smallest element in min-heap]
  • todo CHECK IT!!!! There are at most nodes of height in any -element heap (6.3-3)

Procedures (max heap):

procedurerun timedesc
heapify(A, i)(the height of is )
max-heapify(A, i)
build-max-heap(A)
heap-maximum(A)returns the element of with the largest key
heap-extract-max(A)remove max and retrun it
heap-increase-key(A,i,key)increases the value of to new value (larger or equal)
max-heap-insert(A,key)insert to
  • in min-heap the procedures will be: min-heapify, build-min-heap, heap-minimum, heap-extract-min, heap-decrease-key, min-heap-insert

Binary Search Tree (BST)

  • Type of: Binary Tree

  • Sorted data structure

  • all dynamic set operations take time

  • Traversal (Inorder, preorder, and postorder) take time

  • (12.4) The expected height of a randomly built BST on distinct keys is

Red-Black Tree (RB)

  • Red-Black Tree is Binary Search Tree, which staify the Red-Black tree properties:

    • Every node is either black or red
    • The root is black
    • Every leaf (NIL) is black
    • if node red, then both of its children are black (thus, red nodes black nodes)
    • For each node, all simple paths from the node to leaves have the same number of black nodes, (limiting h ???)
  • is the black-height of the node , which is the number of black nodes on any path from a node (not including) down to a leaf

  • is the black-height of a RB tree, which is the black-height of the root

  • (13.1) A red-black tree with internal nodes has height at most . (which means that it’s approximatly balanced)

  • dynamic set operations take time

Order-statistic tree

  • (Theorem 14.1) Augmenting a red-black tree - Let be a field that augments a red-black tree of nodes, and suppose that the contents of for a node can be computed using only the information in nodes , , and , including and . Then, we can maintain the values of in all nodes of during insertion and deletion without asymptotically affecting the performance of these operations.

  • order-statistic tree is RB Tree with additional node field: size.

    • returns a pointer to the node containing the th smallest key in the subtree rooted at . ( (worst case))
    • returns the position of in the linear order determined by an inorder tree walk of . ( (worst case))

Stack

  • LIFO
desc
Push(S,x)adds an element to the collection
Pop(S)removes the most recently added element that was not yet removed
Stack-empty(S)
Top(S)

Queue

  • FIFO
desc
enqueue(Q,x)g
dequeue(Q)
queue-empty(Q)
queue-full(Q)

Deque

  • (double-ended queue)
desc
head-enqueue(Q,x)g
tail-enqueue(Q,x)g
head-dequeue(Q)
tail-dequeue(Q)