CS4102, Algorithms
Info about Exam 2, Spring 2010
Topics, Slides and Readings:
- Priority Queues, Heaps, and Heapsort
- Slides, plus Johnsonbaugh and Schaefer textbook: Section 3.6,
pp. 133-149
- Note: you won't need to know the implementation of the
Indirect Heap data structure, but you need to know what it does and why
its needed for Prim's MST and Dijkstra's SP algorithms in Ch. 7.
- Searching in Graphs, Backtrack Search
- Slides, plus Johnsonbaugh and Schaefer textbook: Sections
4.2-4.5.
These sections include DFS, BFS, topological sort, and backtracking
(and all related topics covered in class).
- Note: exhaustive search in graphs not covered in book -- see
the slides and handouts.
- Note: the book's coverage of DFS does not include these
topics you should know:
node colors during DFS; edge types (back, cross, etc.); labeling nodes
with discovery and finish times
- State-space search, including best-first search and
heuristics. Note: not coverd in the book -- see the slides and your
notes from lecture. We won't ask details about the code or the
8-puzzle, but may ask about general principles about this.
- Greedy Algorithms
- Slides, plus Johnsonbaugh and Schaefer textbook: Chapter 7
except 7.5
- Note: The slides cover the problems in this reading in a
different order:
Coin changing; Continuous Knapsack; Prim's MST; Kruskal's MST;
Dijkstra's MST
Shortest Path, Activity Selection (slides only)
- Note: questions on Prim's MST algorithm will be based on code
in slides, not version in the book. Undertand the use of the priority
queue!
- Note: questions on Kruskal's MST algorithm will not address
the implementation of the Union/Find disjoint set operations on their
time-complexity.
Sample Exam Questions:
Rather than give you one sample exam, I have gather a collection
showing examples of questions that I have asked
on past exams. Clearly there are more questions here than would be on
any one exam. This list of questions is not
guaranteed to be fully comprehensive, but I think it with the topics
list will help you prepare for the exam. Also see questions on HWs that
were not required to be turned in.
Heap questions:
- Explain why the W(n) for siftdown() is what it is. (The number of
comparisons is 2*floor(lg n)
- What are the assumptions about the Heap and the values stored in
it when siftdown() is called at index i?
- Questions on what the order-classes for various heap operations
might be.
- Given a heap, show what it looks like after "small" operations,
like adding a new item with Insert, or extracting the root item, etc.
- Given an unsorted array, list what calls to siftdown() are made
as we build the heap. Show the tree after each call to siftdown().
BFS and DFS:
- Given an undirected graph and a start node, draw the BFS tree.
Show the distance values from the start node. Draw non-tree edges as
dashed lines.
- Given a graph, draw the DFS tree (or forest). Indicate the
discovery and finish times. Make a list of the back edges (and if a
digraph, the cross and forward edges).
- In the code for dfs(), what lines do we add to identify a
back-edge? To recognize a cycle?
- Given a DFS tree, list the vertices in topological sorted order.
Under what conditions can a digraph not have a valid topological sort?
When we model a problem with topological sort, what does the presence
of an edge between two nodes mean?
- What is the order class of DFS (or BFS) and why? What is the
space complexity?
Greedy Algorithms:
- Principles of the greedy approach
- optimization problems, objective function, feasible
solutions, problem constraints
- greedy rule (AKA selection function, or greedy choice)
- characteristics of greedy algorithms. Also, comparison to
brute-force for optimization problems
- Simple problems: making change; continuous knapsack
- Optimal or not? what's the greedy rule? complexity?
- Minimum spanning tree
- Trace execution of Kruskal or Prim algorithm. Show order
edges added.
- For Kruskal's, don't need to know implementation of
disjoint-set ADT (e.g. nothing from Section 3.6)
- For Prim's, show how candidate edges get updated when needed
for Prim's. Know how the priority queue is used. Understand complexity
when using min-heap and simple unsorted array.
- Don't need to know about indirect heaps.
- Single Source Shortest Path
- Trace execution. Show order edges added. Show distances from
start node.
- Show how candidate edges get updated when needed for
Dijkstra's. Know how the priority queue is used.
- Know that these MST and SP algorithms find optimal solutions.
- Proofs: ask me!