powerpoint presentation · cs 225 exam will run thursday, dec. 14 - monday, dec. 18 (including both...

15
CS 225 Data Structures Nov. 1 – Hashing 3

Upload: others

Post on 31-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

CS 225 Data Structures

Nov. 1 – Hashing 3

Page 2: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

Running Times

Linear Probing: • Successful: ½(1 + 1/(1-α)) • Unsuccessful: ½(1 + 1/(1-α))2

Double Hashing: • Successful: 1/α * ln(1/(1-α)) • Unsuccessful: 1/(1-α)

The expected number of probes for find(key) under SUHA

Page 3: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

ReHashing What if the array fills?

Page 4: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

Running Times

Hash Table AVL Linked List

Find

Amortized: Worst Case:

Insert

Amortized: Worst Case:

Storage Space

Page 5: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

Which collision resolution strategy is better? • Big Records:

• Structure Speed: What structure do hash tables replace? What constraint exists on hashing that doesn’t exist with BSTs? Why talk about BSTs at all?

Page 6: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

std data structures

std::map

Page 7: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

std data structures

std::map ::operator[] ::insert ::erase ::lower_bound(key) Iterator to first element ≤ key ::upper_bound(key) Iterator to first element > key

Page 8: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

std data structures

std::unordered_map ::operator[] ::insert ::erase ::lower_bound(key) Iterator to first element ≤ key ::upper_bound(key) Iterator to first element > key

Page 9: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

std data structures

std::unordered_map ::operator[] ::insert ::erase ::lower_bound(key) Iterator to first element ≤ key ::upper_bound(key) Iterator to first element > key ::load_factor() ::max_load_factor(ml) Sets the max load factor

Page 10: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

CS 225’s Final Exam

Exam Details: CBTF Exam, 3 Hours Long Theory (MCQ) and Programming Questions When you finish your exam, you’re done with CS 225! :) Signup Process: CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday)

You can sign up for your slot starting tomorrow at 9:00am.

Page 11: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

Secret, Mystery Data Structure

ADT: insert remove isEmpty

Page 12: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

Priority Queue Implementation insert removeMin

O(n) O(n)

O(1) O(n)

O( lg(n) ) O(1)

O( lg(n) ) O(1)

Page 13: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

A New Tree Structure

5

15 9

25

4

6

7 20

11 16 12 14

Page 14: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

(min)Heap

5

15 9

25

4

6

7 20

11 16 12 14

4 5 6 15 9 7 20 16 25 14 12 11

Page 15: PowerPoint Presentation · CS 225 Exam will run Thursday, Dec. 14 - Monday, Dec. 18 (including both Saturday and Sunday) You can sign up for your slot starting tomorrow at 9:00am

CS 225 – Things To Be Doing Register for CS 225’s Final Exam! Exam 8 (programming exam, MP4-like and AVL) is live! More Info: https://courses.engr.illinois.edu/cs225/fa2017/exams/

MP5: kd-trees Due Monday, Nov. 6 at 11:59pm

Lab: lab_hash released today Due Sunday, Nov. 5 at 11:59pm

POTD Every Monday-Friday – Worth +1 Extra Credit /problem (up to +40 total)