Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exam 2 Review. Teams Dan C, Z, Hugh, Zane, Alexis Mark, Jamie, Ryan, Alex H, Andrew Katie, Emily, Riley, Rohan, Alex D Dawn, Patrick, Jacapo, Catharine,

Similar presentations


Presentation on theme: "Exam 2 Review. Teams Dan C, Z, Hugh, Zane, Alexis Mark, Jamie, Ryan, Alex H, Andrew Katie, Emily, Riley, Rohan, Alex D Dawn, Patrick, Jacapo, Catharine,"— Presentation transcript:

1 Exam 2 Review

2 Teams Dan C, Z, Hugh, Zane, Alexis Mark, Jamie, Ryan, Alex H, Andrew Katie, Emily, Riley, Rohan, Alex D Dawn, Patrick, Jacapo, Catharine, Lisa Marshall, Lawrence, Dan B, Colby, Michelle Zack, Ben, Jerry, Alex Z, Matt

3 1. Suppose a heap has 6 nodes. What is the height of the heap? (Remember the root is at height 0).

4 2. Suppose you have a binary search tree with 6 nodes. What is the range of what the height of the tree may be?

5 3. Suppose that a hash table has 50 slots and only 10 keys. What is its load factor?

6 4. Give one pro of an array over a linked list and vice versa.

7 5. When would you prefer to use a heap rather than a binary search tree?

8 6. What data structure is implemented using a heap?

9 7. What is the main operation supported by a heap?

10 8. What is the main operation supported by a BST?

11 9. Could this be a heap? Why or why not? 18 3 3 8 8 9 9 10 12

12 10. I’m going to empty a binary search tree by successively finding the smallest element, printing it, and then deleting it until the tree is empty. What’s the best case running time?

13 11. What are the two schemes for storing edges?

14 12. What is the running time of depth-first search?

15 13. When would I prefer to use breadth-first rather than depth-first search?

16 14. Dijkstra’s algorithm is O((V+E)(lgV)). Where does the lgV term come from?

17 15. How do you perform a topological sort?

18 16. How can you tell if a graph is connected?

19 17. A connected, acyclic graph is called …

20 18. The two algorithms that compute MSTs are

21 19. When is Dijkstra’s not used for computing shortest paths?

22 20. What does “linear probing” refer to?

23 21. Consider the adjacency matrix: Is the graph directed? Weighted? Dense or sparse? 14 3 8 3 6 3 23 0 2 4 13 21 3 5 0 14 3 8 3 6 3 23 0 2 4 13 21 3 5 0

24 22. When would you prefer to use an adjacency list rather than an adjacency matrix?

25 23. What properties of a graph are necessary for a topological sort?

26 24. What makes an algorithm “greedy”? Give an example.

27 25. What is the running time of Kruskal’s?

28 26. What properties of a graph are necessary for running Prim’s algorithm?

29 27. What operations should be supported by a hash table?

30 28. What is the running time for inserting or deleting from a hash table if there is a good hash function?

31 29. What are the 2 types of hash tables?

32 30. When would you prefer to use a chaining table rather than an open-address table?

33 All-Play Run Depth-First on the following graph and classify each edge: B B E E G G H H C C F F D D A A

34 All-Play Use both Kruskal’s and Prim’s to calculate MSTs. Use alphabetical order for Prim’s. A A E E F F B B G G C C H H D D 1 1 8 6 62 1 4 4 3 2 5 1

35 All-Play Use Dijkstra’s to compute shortest paths from A. A A E E F F B B G G C C H H D D 1 1 8 6 62 1 4 4 3 2 5 1

36 Design an algorithm that takes as input a connected, undirected graph and computes whether or not there exists an edge in the graph that can be removed and still leave the graph connected. Tell the running time of your algorithm. Feel free to call any algorithm we’ve discussed (you don’t have to re-write the algorithm). boolean REMOVE-BUT-CONNECTED(G)

37 Write an algorithm that decreases the value of an element in a heap. Use known heap functions. What is the running time? DECREASE_KEY(Heap H, KeyIndex K, Integer Amt):

38 Write an algorithm that computes the number of nodes in a BST. left(N) gives the left node of N and right(N) gives the right. int SIZE(BST N):


Download ppt "Exam 2 Review. Teams Dan C, Z, Hugh, Zane, Alexis Mark, Jamie, Ryan, Alex H, Andrew Katie, Emily, Riley, Rohan, Alex D Dawn, Patrick, Jacapo, Catharine,"

Similar presentations


Ads by Google