Download presentation

Presentation is loading. Please wait.

Published byGwendolyn Morris Modified over 4 years ago

1
Final Review Dr. Yingwu Zhu

2
Goals Use appropriate data structures to solve real- world problems –E.g., use stack to implement non-recursive BST traversal, –use queue to implement BST level traversal, –use stack to implement non-recursive quicksort –use heaps to do heapsort, and priority queues Use appropriate algorithms to slove real-world problems –Search algorithms –Sorting algorithms

3
Goals Use Big-Oh notation to evaluate algorithm efficiency Understand ADTs including BST, Heap, Priority Queue, AVL trees Understand hashing Understand sorting algorithms

4
ADTs Tree terminologies BST AVL Trees Heap Priority Queue

5
Trees Binary trees Complete trees Balanced trees Level Height

6
BST Definition Recursive ADT Implementing a BST (recursive and non- recursive) –Search –Traversals (in-order, pre-order, post-order) –Insertion –Deletion –Other operations: height, level, …

7
BST T(n) = ? Is BST balanced? Lopsidedness problem! BST AVL trees

8
AVL Trees Definition Four rotation techniques –Single rotations –Double rotations Key to perform rotation: identify the nearest ancestor with BF of +2 or -2 for the inserted item Two steps in double rotations –Rotate child and grandchild nodes of the ancestor –Rotate the ancestor and the new child node

9
Heap Defintion Recusive data structure Semiheap What data structures are good to implement a heap? Why? Parent-child relationships

10
Heap Implementation –Insertion –Deletion –removeMax –Other operations? Two basic operations –Percolate down –Percolate up

11
Priority Queue Definition Using different ADTs to implement priority queue –Unsorted lists –Sorted lists –BST –Heap Why heap is a good choice?

12
Hashing Why need hashing? Definition of hash function? Problem of hashing: collision

13
Hashing Collision resolution techniques –Open addressing Linear probing Quadratic probing Double hashing –Chaining

14
Hashing Three strategies to improve hashing performance –Increase hash table capacity –Use a good hash function (how to evaluate a hash function?) –Use a good collision resolution technique

15
Algorithm Efficiency Big-Oh notation definition T(n) Non-recursive algorithms –The most executed instruction Recursive algorithms: telescoping principal –Anchor case –Inductive step

16
Sort Selection sort, insertion sort, bubble sort Heapsort Quicksort Mergesort

17
Selection Sort How does it work? T(n) = ?

18
Insertion Sort How does it work? T(n) = ? Recursive and Non-recursive algorithms

19
Bubble Sort How does it work? How does it detect partially sort sublist to improve performance T(n) = ? Best case performance Worst case performance

20
Quicksort How does it work? –Devide and conquer Basic operation –Split based on pivot T(n) = ? best case and worst case?

21
Quicksort How to improve performance –Median-of-three rule in pivot choice –Short sublists are handle first in recursive alg. –Non-recursive –Other solutions

22
Mergesort Internal and external algorithm Basic operation: split and merge Divide-and-conquer T(n) = ?

23
Heapsort Heapify process How does heapsort work? –Exploits heap property –T(n) = ?

24
About Final Exam Must >= 75 to pass Multiple choices Short answers Coding Reminder: do not loose points in basic concept questions! Good luck!

Similar presentations

© 2020 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google