1 / 26

Final Exam Review

Final Exam Review. 6 December 2010. 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

merrill
Télécharger la présentation

Final Exam Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 December @ 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 December @ 1:00 p.m. – 3:00 p.m. in HEC 101 with Remo • Wednesday, 8 December @ 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

  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 • 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

  23. Review Question 9

  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? 3 3  7  6  2  0 No. Because of insufficient weight info.

  25. Review Question 10 • CHEESE!

  26. Good Luck on the Final Exam

More Related