1 / 12

CSE 326: Data Structures: Midterm Review

This lecture provides a review of key topics for the upcoming midterm, including math background, algorithm analysis, lists, stacks, queues, trees, search trees, priority queues, and hashing. Study materials and practice problems are provided.

lawrencem
Download Presentation

CSE 326: Data Structures: Midterm 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. CSE 326: Data Structures: Midterm Review Lecture 15: Monday, Feb 10, 2003

  2. The Midterm Mechanics • Wednesday, 2/12/2003, 1:30-2:20 (50’) • We may start a few minutes early so you have > 50’ • Chapters 1-6 in the textbook • Closed book, closed notes, except: • You may bring one 8 ½” x 11” sheet of handwritten notes • Bring pens and/or pencils

  3. The Midterm Practice: • Read the book, the lecture notes, review the homeworks • Practice midterm and solutions are on the website • Our midterm will be a bit more challenging • Make sure you sleep well the night before • Enjoy it ! We have fun questions

  4. Midterm Review:Math Background • Big-Oh, big-omega, and theta notations: • T(n) = O(f(n)) if there exists c, n0 s.t. forall n > n0, T(n) < c f(n) • Should we have n  n0, and T(n)  c f(n) instead ? • O(f(n)) means “less than or equal to” f(n) • (f(n)) means “greater than or equal to” f(n) • (f(n)) means “same as” f(n)

  5. Summations for (i=1; i<=n; i++) for (j=1; j<=i; j++) print “hello” Summations are easy...

  6. Recurrences f(n) = f(n-1) + n  O(n2) f(n) = f(n-1) + 1  O(n) f(n) = 2f(n-1)+1  O(2n) f(n) = 2f(n/2) + 1  O(n) ...recurrencesare hard ! f(n) = 2f(n/2) + n  O(n log n) f(n) = f(n/2) + 1  O(log n) f(n) = f(n/5) + f(3n/5) + n  O(n) f(n) = f(n-1) + f(n-2)  O(n)

  7. Algorithm Analysis • T(n) = running time for inputs of “size” n • The “size” does not tell us everything about the input; hence: • Worst case T(n) • Average case T(n) • Best case T(n) • Analyze the algorithm: • Find f(n) s.t. T(n) = O(f(n)) • Find f(n) s.t. T(n) = (f(n)) • Need to pick f(n) to be a simple function • Amortized analysis !

  8. List, Stacks, Queues • Lists: insert, find, delete • Singly-linked lists with header node • Doubly-linked lists and circular lists • Runtime and space needed for array-based v.s. pointer based • Stacks: push, pop • Pointer v.s. array implementations • Use of stacks in balancing symbols (recall the homework) • Queues: equene, dequeue • Array-based v.s. list based implementations

  9. Trees • Terminology: • Root, children, parent, path, height, depth, ... • Preorder, postorder, inorder traversal of a tree • Can do recursively, or with a stack, or with pointers to parents

  10. Search Trees • BST • Definition • Find, insert, delete • AVL trees • Definition, running times • Know the rotation cases (we wont ask you to write the code, but may ask you to show on an example) • Splay trees • Definition, running times • B-trees

  11. Priority queues: binary heaps • Definition, implementation • Main operations: • findMin, insert, deleteMin • Other operations: • decreaseKey, increaseKey • Binomial heaps: merge • No need to know details of leftist or skew heaps

  12. Hashing • Know how hash functions work: • Hash(k) = k mod TableSize • TableSize is chosen to be a prime, when the keys are integers • Collisions: • Chaining: colliding values  linked list • Open addressing: works when table is not very full. Linear probing, quadratic probing, double hashing • Extensible hash tables That’s all, folks ! See you on Wednesday

More Related