Midterm Review for CMPS 2200, Fall 2015

Relevant Material:

  1. Analyzing Algorithms
  2. Asymptotic Notation (О, Ω, Θ, ο)
  3. Heaps
    • Min-heap property, heap definition
    • Using array implementation, findMin takes O(1) time, and extractMin and decreaseKey take O(log n) time
    • Heapsort: Repeatedly extract min in min-heap; O(n log n) time
  4. Red black trees:
    • Properties of binary search trees
    • Properties of red black trees
      • If black-height is b and the height of the tree is h, then b<=h<=2b
      • h = b when all the nodes in the tree are black
      • h=2b when you have red and black nodes in alternating levels
    • Sample Questions:
      • Justify whether a given tree is a legal red black tree / binary tree / balanced search tree
      • Show rotations on a binary search tree
      • Maximum and minimum number of elements in a red black tree with black height b
  5. B-Trees:
    • A B-tree with minimum degree k >= 2 has the following properties:
      • Number of keys in root: 1<= #keys <= 2k-1
      • Number of keys in other nodes: k-1 <=  #keys <= 2k-1
      • Each node has exactly #keys stored in that node + 1 number of children
      • All leaves are in the same level
      • Only a root split can increase the height of a B-tree
    • Sample Questions:
      • For a given tree justify if it is a legal B-tree
      • For a given set of numbers come up with all possible legal B-trees
      • Maximum and minimum number of keys possible to store in a B-tree
      • Insertion in a B-tree (use preemptive splitting, and show node split if needed)
  6. Recursion:
    • Divide & Conquer
      • You can call an algorithm Divide and Conquer only if the size of subproblems can be written as n/b where b>1
    • Regular Recursion
      • Subproblems can be of size n-1, n-2, n-3 etc.
    • Recursive algorithms and thinking
      • Find a recursive solution to a problem; recursive pseudocode
      • Recursive squaring, multiplying n-bit integers, Strassen's algorithm
    • Runtime recurrence
      • Find the runtime recurrence for a recursive algorithm given in pseudocode
  7. Solving Recurrences: Solve a runtime recurrence (i.e., find an upper bound for a recursively defined T(n)):
    • Recursion Tree: Find a guess what a (runtime) recurrence could solve to using recursion trees
      • Given T(n) = aT(n/b) + f(n)
      • a = #of subproblems = #of children at each node
      • n/b = subproblem size
      • Height of the tree = log_b (n) [log of n base b]
    • Master Method
      • Find the value of a and b
      • Compute n^(log_b (a) and compare with O(f(n))
      • Please clearly write which case it is and give the values for epsilon, k, and c:
        • For case 1: Give the value of epsilon>0
        • For case 2: Give the value of k>=0
        • For case 3: Give the value of epsilon>0, check the regularity condition and give the value of c<1
  8. Dynamic Programming (DP):

Practice Problems from the Book: