Presentation is loading. Please wait.

Presentation is loading. Please wait.

Final Exam Review 6 December 2010.

Similar presentations


Presentation on theme: "Final Exam Review 6 December 2010."— Presentation transcript:

1 Final Exam Review 6 December 2010

2 Assignment #5 Will be due tonight @ 11:59 p.m.
Take a look at my “Review Notes” if you still have no idea how to approach the problem Stars in cells with no dependencies Runtime issue We will not impose runtime constraints, but you have to use backtracking Be aware that we will do less bug-fixing

3 Final Exam Information
On Monday, 13 4:00 p.m. – 6:50 p.m. (NOT 4:30 p.m.) You are allowed 3 sheets of letter-sized paper with notes Review Sessions: Tuesday, 7 1:00 p.m. – 3:00 p.m. in HEC 101 with Remo Wednesday, 8 1:00 p.m. – 3:00 p.m. in HEC 101 with Chris

4 Review Question 1 Network Flow Proposed Solution:

5 Review Question 1 Counter Example: Maximum Flow will be 10
BUT: book is “split up” between boxes x1 and x2

6 Review Question 2 Edit Distance Remember:

7 Review Question 3 Backtracking
You are given a set of letters, in random order, e.g. “OFCEFI” You have to determine whether or not there exists a way to reorder those letters to form a valid word. Given: A function “startswith(a)”, that determines if there are any words that start with the string “a”

8 Review Question 3 Backtracking function jumbledLetters(a, b) takes in a set of letters, a, already ordered, and set of letters, b, that needs to be added Base Cases: If startswith(a) == FALSE, return FALSE If b is empty string, return startswith(a) Recursively call jumbledLetters() with next set of letters If any of recursive calls return TRUE, return TRUE If all return FALSE, return FALSE

9 Review Question 3 Example: Call to jumbledLetters(“OF”, “CEFI”)

10 Review Question 4 Single Room Scheduling (Lecture 11) Greedy Solution:
Sort the requests by finish time. Go through the requests in order of finish time, scheduling them in the room if the room is unoccupied at its start time.

11 Review Question 4 Show Time Cops 6:30 – 7:30 CSI 7:30 - 8:30 30 Rock
7:00 - 9:00 Office 8:00 - 9:00 Idol 6:00 - 9:15 Survivor 8:45 - 9:45 24 7: :30 Law & Order 9: :50 SportsCenter 9: :00 Show Time Cops 6:30 – 7:30 CSI 7:30 - 8:30 Survivor 8:45 - 9:45 Law & Order 9: :50 Maybe ask about how to do Multiple Room Scheduling?

12 Review Question 5 MakeHeap (Lecture 4)
Place all the unsorted elements in a complete binary tree. Going through the nodes in backwards order, and skipping the leaf nodes, run Percolate Down on each of these nodes. If one of the children is less than the node, swap the lowest. Continue until node has only larger (or equal) children or until leaf node

13 Review Question 5 Initial Heap:

14 Review Question 5 Final Heap:

15 Review Question 6

16 Review Question 6 Solution:

17 Review Question 6 Usually a good idea to break down initial equation as much as possible before proceeding

18 Review Question 7 Code Analysis Matrix Chain Multiplication
What problem does this code solve? Symbolically, what does the variable “m” represent? Matrix Chain Multiplication At which matrix you want to split your multiplication a the top level.

19 Review Question 7 Explain conceptually what is stored in the variables “one”, “two”, and “three”. Is the method “function” efficient? Justify. “one” stores number of multiplications to do the left-side product “two” stores number of multiplications to do the right-side product “three” stores number of multiplications to take the two products from two recursive calls and multiply them No. The exact same recursive call gets made multiple times.

20 Review Question 8

21 Review Question 8

22 Review Question 8 Additional Question: Why don’t we just use Bucket Sort for all our sorting? Answer: Because it takes a lot of space and makes the assumption of uniform distribution? Worst-case runtime is still O(N^2). For all practical intents and purposes, QuickSort is the fastest sorting out there.

23 Review Question 9 Index 1 2 3 4 5 6 7 8 9 Value

24 Review Question 9 Which row (0 – 9) is this in the path array? Determine the vertices traversed in the shortest path from vertex 3 to vertex 0. From the information given, can we determine which vertex is farthest away from vertex 3? Why or why not? Index 1 2 3 4 5 6 7 8 9 Value 3 3  7  6  2  0 No. Because of insufficient weight info.

25 Review Question 10 CHEESE!

26 Good Luck on the Final Exam


Download ppt "Final Exam Review 6 December 2010."

Similar presentations


Ads by Google