340 likes | 470 Views
Exam 2 Review. Teams. Brian S, Peter T, Rex, Brian H George, Daniel S, Fritz, Kristen Gavan, Asher, Peter D, Spencer Dan M, Emma, Dillon, Emily Kaylin , Colin, Jerry, Alex S Chad, Sam, Matt B, Seth Matt M, Heather, James, Alex D. 1.
E N D
Teams • Brian S, Peter T, Rex, Brian H • George, Daniel S, Fritz, Kristen • Gavan, Asher, Peter D, Spencer • Dan M, Emma, Dillon, Emily • Kaylin, Colin, Jerry, Alex S • Chad, Sam, Matt B, Seth • Matt M, Heather, James, Alex D
1. • A sort whose main operation is finding whether or not 2 elements are <, >, or = is called…
2. • A sort in which equal elements stay in their original order is called…
3. • What does it mean for a sort to be in-place?
4. • What is the worst case running time of Bucket sort? When does it happen?
5. • What is the worst-case running time for quicksort? When does that happen?
6. • What are the two schemes for storing edges?
7. • What is the running time of depth-first search?
8. • When would I prefer to use breadth-first rather than depth-first search?
9. • Dijkstra’s algorithm is O((V+E)(lgV)). Where does the lgV term come from?
10. • How do you perform a topological sort?
11. • How can you tell if a graph is connected?
12. • A connected, acyclic graph is called …
13. • The two algorithms that compute MSTs are
14. • When is Dijkstra’s not used for computing shortest paths?
15. • What shortest-path algorithm should be used if there are negative weights in the graph?
16. • Consider the adjacency matrix: • Is the graph directed? • Weighted? • Dense or sparse? 1 4 3 8 6 3 23 0 2 4 13 21 3 5 0
17. • What is the running time of count sort?
18. • What paradigm of problem-solving is Huffman’s encoding scheme?
19. • When would you prefer insertion sort rather than quicksort?
20. • Quicksort’s Recurrence Relation is: • T(n) = 2T(n/2) + n • Where does the n term come from?
21. • What is the running time of radix sort?
22. • When would you prefer to use an adjacency list rather than an adjacency matrix?
23. • What properties of a graph are necessary for a topological sort?
24. • What makes an algorithm “greedy”? Give an example.
25. • Which sort has its best case when it is in reverse order?
26. • What is the running time of Kruskal’s?
27. • What properties of a graph are necessary for running Prim’s algorithm?
28. • You are watching a sorting animation for linear sorts. What do you look for to distinguish bucket sort from other linear sorts?
All-Play • Run Depth-First on the following graph and classify each edge: A C B D G H E F
All-Play • Use both Kruskal’s and Prim’s to calculate MSTs. Use alphabetical order for Prim’s. 3 2 1 D A B C 6 2 8 4 4 1 6 E F G H 1 1 5
All-Play • Use Dijkstra’s to compute shortest paths from A. 3 2 1 D A B C 6 2 8 4 4 1 6 E F G H 1 1 5
All-play • Suppose symbols a, b, c, d, and e occur with frequency 3/9, 2/9, 2/9, 1/9, 1/9. What is the huffman encoding of the symbols?