Midterm Study Guide

Midterm Structure

  • Coding Portion: Modifications of LinkedList (Circular / jump-to-end / doubly-linked); non-scary OOP skeleton 🙈
  • Multiple Choice Portion: Lots more to cover…
    • Hash Tables: \(O(1 + \epsilon \log_2(n))\), but think about it as:
    • \(1 + (\text{Collision rate}) \cdot (\text{Collision handler efficiency})\)
    • Linked List \(\rightarrow\) Binary Search Tree
    • Depth-First vs. Breadth-First: Picture of a tree \(\rightarrow\) (a) what is BFS result, (b) what is (in/pre/post)-order DFS result?
    • Lastly: Cormen, Leiserson, Rivest, Stein (CLRS), pgs. 17-106

The Two Boxes That Most Things In This Course Can Be Sorted Into

  • Box 1: Linear Things
  • Box 2: Logarithmic Things
  • Things that go into the boxes:
    • Algorithms
    • Data Structures
    • Software Development Patterns

The Boxes

Linear Things: \(O(N)\) Logarithmic Things: \(O(\lg{N})\)
Data Structures

LinkedList

BinarySearchTree

Sorting Algorithms Insertion-Sort Merge-Sort
Search Algorithms Linear-Search Binary-Search
General Pattern One-by-One Divide-and-Conquer
Steps to Look Up a Word \(N = 102118\) \(\lceil \log_2(N) \rceil = 17\)
  • Hash Table: A “trick” that gets us close to \(O(1)\), by pre-allocating lots of memory!

\[ O(N) \; \underbrace{\leadsto O(\log_2(N))}_{\mathclap{\substack{\text{More Efficient Algorithm} \\ \text{(Free!)}}}} \; \underbrace{\leadsto O(1 + \epsilon\log_2(N))}_{\substack{\text{More Memory} \\ \text{(\$\$\$)}}} \]