Final Review for CMPS 2200, Fall 2012
[Roughly 40-50% from new material, 60-50% from other (materials covered in
tests 1 and 2 )]
Relevant Material:
- All material from 9/3/12 until 11/29/12 (inclusive); no approximation algorithms.
- This includes all material covered in the lectures, and all homeworks and projects.
- The covered chapters in the book are 0.3 and 2.1,2,3,4,5 (not 2.6) and 3.1,2,3 (not 3.4) and 4 and 5.1 and 6.2,3 (we covered LCS which is similar), 6.4,6 and parts of 8.1,2. Note that on some of the topics we covered additional details in the lectures (e.g., Master Theorem, randomized algorithms, topological sort, amortized analysis, LCS, making change).
- Review for Test 1
- Review for Test 2
- New Material:
- 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
- Insertion (show rotations if needed)
- Maximum and minimum number of elements in a Red Black Tree with
black height b
- B-Trees:
- A B-tree with
minimum dregree k >= 2 has following properties
- Number of keys in root: 1<= #keys <= 2k-1
- Number of keys in other nodes:
k-1 <=
#keys <= 2k-1
- Each node will have exactly #keys stored in that node + 1
number of children
- All leaves will be 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 (show node split if needed)
- Dynamic Programming (DP):
- An algorithm design
technique where
- each subproblem is solved only once and the solution
is stored in a dynamic programming table (DP table)
- and this stored value/solution will be used later
whenever needed
- This approach applies only if the problem has
the following two
properties:
- overlapping subproblems
- optimal substructure
- Sample Questions:
- Understand a given recursive solution, and
analyze the time and space needed for a
brute-force implementation of the recursion.
- Develop a recursive solution for a problem similar to problems covered in class or on the homework.
- Design a DP algorithm using a given recurrence and either
of the following approaches
- Bottom-up: this approach uses
a loop and fills the whole DP table bottom-up.
- Memoization: this approach uses
recursion and fills only the cells of the DP table which are needed during the recursion.
- Analyze time and space of your DP algorithm
- Give an algorithm to fill the DP Table for a given recursive solution and compute the
solution from it
- Greedy Algorithms
- Greedy Strategies:
- repeatedly identify the decision
to be made (recursion)
- make a locally optimal choice for each decision
- Greedy does not always work.
- All Pairs Shortest Paths
- Floyd-Warshall:
- Runtime: O(|V|^3) [when adjacency matrix is
given]
- Dijkstra: Run single source
Dijkstra once for each vertex as source.
- Bellman-Ford: Run single source Bellman-Ford
once for each vertex as source.
- P and NP
- Definition of P, NP, NP-hard, NP-Complete
- Reductions, NP-complete problems (SAT, Clique, TSP, HC, Vertex Cover, Independent Set)