Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 326: Data Structures: Midterm Review

Similar presentations


Presentation on theme: "CSE 326: Data Structures: Midterm Review"— 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 Summations are easy... 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 f(n) = f(n-1) + 1 f(n) = 2f(n-1)+1
 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) f(n) = 2f(n/2) + n ...recurrences are hard !  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 Stacks: push, pop
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: Preorder, postorder, inorder traversal of a tree
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 AVL trees Splay trees B-trees 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 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: Collisions:
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


Download ppt "CSE 326: Data Structures: Midterm Review"

Similar presentations


Ads by Google