Presentation is loading. Please wait.

Presentation is loading. Please wait.

Review I. Final exam Date TBD. Don ’ t be late! Open book, open notes No calculators or any electronics Worth 50% of final grade.

Similar presentations


Presentation on theme: "Review I. Final exam Date TBD. Don ’ t be late! Open book, open notes No calculators or any electronics Worth 50% of final grade."— Presentation transcript:

1 Review I

2 Final exam Date TBD. Don ’ t be late! Open book, open notes No calculators or any electronics Worth 50% of final grade

3 Office hours TBD

4 Material for preparation Lecture notes: http://www.cs.mcgill.ca/~blanchem/250/schedule.html See solutions to five homeworks for what I consider clear and complete solutions. 3 final exams available online at MUSE: http://www.library.mcgill.ca/ you need to sign-in and give the bar code number on your student card –Spring 2001 exam (Ignore page 6, page 8) –Spring 2003 exam (Ignore Q3, Q4 (polynomials)) 39 more problems at: http://www.cs.mcgill.ca/~blanchem/250/revision.html

5 Topics covered No java questions; only pseudocode All other material is going to be examined, with some emphasis on post-midterm material Material not covered in homeworks (i.e. starting with undecidability) will be covered in the final, but with less emphasis

6 Recursion Designing recursive algorithms –Break problem into smaller subproblems of the same nature –Solve subproblems recursively –Combine solutions of subproblems into solution of large problem –Don ’ t forget your base case! Dividing original problem into roughly equal size subproblem usually gives better running times –Power (lecture7) vs power (hw2) –slowMergeSort (midterm) vs mergeSort –quickSort (good pivot choice) vs quickSort (bad pivot) –integer multiplication Tracing recursion (like in hw4)

7 Recursion Trees: recursion usually easier (try isIsomorphic without recursion!) Analysis of running time of recursive algorithms –Writing recurrences for T(n) –Solving recurrences using substitution method or recursion tree method. –Master theorem can only be user for T(n) = a T(n/b) + f(n) –Using induction to prove the explicit formula for T(n)

8 Running time and big-Oh Running time: –Counting primitive operations –Dealing with loops (e.g. midterm Q1)  n i=1 i = n (n+1)/2 is O(n 2 ) –Worst-case vs average-case vs best-case Big-Oh notation: –Mathematical definition –Proving big-Oh relationships From the definition Using simplification rules Using limit of ratio Big-Oh hierarchy –Big-Oh is relevant only for large inputs. For small inputs, big-Oh may be irrelevant (remember integer multiplications) Big-Theta, Big-Omega Unless mentioned otherwise, big-Oh running time is for worst-case. Master-theorem for recurrences You need to know and understand the big- Oh running time of all algorithms seen in class and in homeworks.

9 Data structures Array: –running time for insert, delete, find... Single-linked list –Better than arrays: Easier to insert and delete No need to know size in advance –Worse than arrays: finding the n-th element is slow (so binarySearch is hard) Require more memory (for the "next" member) Doubly-linked list –Allow to move backward –Makes deleting elements easier Stacks and queues –You should understand all applications we saw

10 ADT (Abstract Data Structure) What it is: –Description of the interface of a data structure: Specifies what type of data can be stored What kind of operations can be performed Hides the details of implementation –Why it is important: Simplifies the way we think of large programs


Download ppt "Review I. Final exam Date TBD. Don ’ t be late! Open book, open notes No calculators or any electronics Worth 50% of final grade."

Similar presentations


Ads by Google