COMPUTER 2430 Object Oriented Programming and Data Structures I

Slides:



Advertisements
Similar presentations
CS 206 Introduction to Computer Science II 11 / 17 / 2008 Instructor: Michael Eckmann.
Advertisements

CS 206 Introduction to Computer Science II 11 / 12 / 2008 Instructor: Michael Eckmann.
Data Structures Using C++ 2E Chapter 9 Searching and Hashing Algorithms.
CS 206 Introduction to Computer Science II 04 / 06 / 2009 Instructor: Michael Eckmann.
1 5. Abstract Data Structures & Algorithms 5.2 Static Data Structures.
Hashing Hashing is another method for sorting and searching data.
HASHING PROJECT 1. SEARCHING DATA STRUCTURES Consider a set of data with N data items stored in some data structure We must be able to insert, delete.
Hashing - 2 Designing Hash Tables Sections 5.3, 5.4, 5.4, 5.6.
Hash Tables ADT Data Dictionary, with two operations – Insert an item, – Search for (and retrieve) an item How should we implement a data dictionary? –
Searching Tables Table: sequence of (key,information) pairs (key,information) pair is a record key uniquely identifies information, so no duplicate records.
CS 206 Introduction to Computer Science II 04 / 08 / 2009 Instructor: Michael Eckmann.
CS203 Lecture 14. Hashing An object may contain an arbitrary amount of data, and searching a data structure that contains many large objects is expensive.
Hashing: Collision Resolution Schemes
Chapter 27 Hashing Jung Soo (Sue) Lim Cal State LA.
Hashing.
Collision Resolution: Open Addressing
Data Structures Using C++ 2E
CSE373: Data Structures & Algorithms Lecture 6: Hash Tables
CSCI 210 Data Structures and Algorithms
Alternative method for dictionary building : Hashing
Slides by Steve Armstrong LeTourneau University Longview, TX
Hash Tables (Chapter 13) Part 2.
EEE2108: Programming for Engineers Chapter 8. Hashing
Data Structures Using C++ 2E
CS223 Advanced Data Structures and Algorithms
Advanced Associative Structures
Hash Table.
Hash Table.
Chapter 28 Hashing.
Instructor: Lilian de Greef Quarter: Summer 2017
Hash In-Class Quiz.
CSE373: Data Structures & Algorithms Lecture 14: Hash Collisions
Hash Tables.
Chapter 21 Hashing: Implementing Dictionaries and Sets
External Memory Hashing
Resolving collisions: Open addressing
CSE373: Data Structures & Algorithms Lecture 14: Hash Collisions
Searching Tables Table: sequence of (key,information) pairs
Data Structures and Algorithms
COMPUTER 2430 Object Oriented Programming and Data Structures I
Hash Tables Chapter 12 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common.
Overflow Handling An overflow occurs when the home bucket for a new pair (key, element) is full. We may handle overflows by: Search the hash table in some.
CS202 - Fundamental Structures of Computer Science II
A Hash Table with Chaining
COMPUTER 2430 Object Oriented Programming and Data Structures I
Given value and sorted array, find index.
COMPUTER 2430 Object Oriented Programming and Data Structures I
Overflow Handling An overflow occurs when the home bucket for a new pair (key, element) is full. We may handle overflows by: Search the hash table in some.
CS 2430 Object Oriented Programming and Data Structures I
Overflow Handling An overflow occurs when the home bucket for a new pair (key, element) is full. We may handle overflows by: Search the hash table in some.
Hash Tables Chapter 12 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common.
COMPUTER 2430 Object Oriented Programming and Data Structures I
Collision Resolution: Open Addressing
Overflow Handling An overflow occurs when the home bucket for a new pair (key, element) is full. We may handle overflows by: Search the hash table in some.
Data Structures – Week #7
Ch Hash Tables Array or linked list Binary search trees
Collision Handling Collisions occur when different elements are mapped to the same cell.
Ch. 13 Hash Tables  .
What we learn with pleasure we never forget. Alfred Mercier
Hash Maps Introduction
Hash Maps Implementation and Applications
Hash Tables: Associative Containers with Constant Time Operations --- On Average Consider the problem of computing the frequency of words.
Extendable hashing M.B.Chandak.
DATA STRUCTURES-COLLISION TECHNIQUES
17CS1102 DATA STRUCTURES © 2018 KLEF – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS RESERVED.
Collision Resolution: Open Addressing Extendible Hashing
Hashing: Collision Resolution Schemes
Chapter 5: Hashing Hash Tables
Collision Resolution: Open Addressing
Collision Resolution: Open Addressing
Presentation transcript:

COMPUTER 2430 Object Oriented Programming and Data Structures I

Handling Collision Linear Probe (Open Addressing): Go to the next available slot (circular) Double Hashing: Use a second hashing function if collision occurs (circular) Buckets Each array slot points to an array (2-D array) Quiz is coming? Program due! 2 2 2

Double Hashing First Hashing Function h1: index = h1(key) = key % table_size Second Hashing Function h2 for collision: step = h2(key) = 1 + key % AnotherPrime Quiz is coming? Program due! 3 3 3 3

Twin Primes 11 and 13 17 and 19 1229 and 1231 Donald Knuth Table size : the larger one AnotherPrime: the smaller one Quiz is coming? Program due! 4 4 4 4

Example/Exercise Index = h1(key) = key % 13 Step = h2(key) = 1 + key % 11 Key : 21 60 86 23 75 62 32 45 58 Index: ? ? ? ? ? ? ? ? ? 8 8 8 10 10 10 6 6 6 Step : ? ? ? ? ? ? ? ? ? 11 6 10 2 10 8 11 2 4 21

Example/Exercise Index = h1(key) = key % 13 Step = h2(key) = 1 + key % 11 Key : 21 60 86 23 75 62 32 45 58 Index: ? ? ? ? ? ? ? ? ? 8 8 8 10 10 10 6 6 6 Step : ? ? ? ? ? ? ? ? ? 11 6 10 2 10 8 11 2 4 21 60 21

Example/Exercise Index = h1(key) = key % 13 Step = h2(key) = 1 + key % 11 Key : 21 60 86 23 75 62 32 45 58 Index: ? ? ? ? ? ? ? ? ? 8 8 8 10 10 10 6 6 6 Step : ? ? ? ? ? ? ? ? ? 11 6 10 2 10 8 11 2 4 60 21 60 86 21

Example/Exercise Index = h1(key) = key % 13 Step = h2(key) = 1 + key % 11 Key : 21 60 86 23 75 62 32 45 58 Index: ? ? ? ? ? ? ? ? ? 8 8 8 10 10 10 6 6 6 Step : ? ? ? ? ? ? ? ? ? 11 6 10 2 10 8 11 2 4 60 86 21 60 86 21 23

Example/Exercise Index = h1(key) = key % 13 Step = h2(key) = 1 + key % 11 Key : 21 60 86 23 75 62 32 45 58 Index: ? ? ? ? ? ? ? ? ? 8 8 8 10 10 10 6 6 6 Step : ? ? ? ? ? ? ? ? ? 11 6 10 2 10 8 11 2 4 60 86 21 23 60 86 75 21 23

Example/Exercise Index = h1(key) = key % 13 Step = h2(key) = 1 + key % 11 Key : 21 60 86 23 75 62 32 45 58 Index: ? ? ? ? ? ? ? ? ? 8 8 8 10 10 10 6 6 6 Step : ? ? ? ? ? ? ? ? ? 11 6 10 2 10 8 11 2 4 60 86 75 21 23 62 60 86 75 21 23

Example/Exercise Index = h1(key) = key % 13 Step = h2(key) = 1 + key % 11 Key : 21 60 86 23 75 62 32 45 58 Index: ? ? ? ? ? ? ? ? ? 8 8 8 10 10 10 6 6 6 Step : ? ? ? ? ? ? ? ? ? 11 6 10 2 10 8 11 2 4 62 60 86 75 21 23 62 60 86 32 75 21 23

Example/Exercise Index = h1(key) = key % 13 Step = h2(key) = 1 + key % 11 Key : 21 60 86 23 75 62 32 45 58 Index: ? ? ? ? ? ? ? ? ? 8 8 8 10 10 10 6 6 6 Step : ? ? ? ? ? ? ? ? ? 11 6 10 2 10 8 11 2 4 62 60 86 32 75 21 23 62 60 86 32 75 21 23 45

Example/Exercise Index = h1(key) = key % 13 Step = h2(key) = 1 + key % 11 Key : 21 60 86 23 75 62 32 45 58 Index: ? ? ? ? ? ? ? ? ? 8 8 8 10 10 10 6 6 6 Step : ? ? ? ? ? ? ? ? ? 11 6 10 2 10 8 11 2 4 62 60 86 32 75 21 23 45 62 60 86 32 75 21 58 23 45

Quiz 6 Wednesday, December 5 Binary Search Hashing Counting

Prog 6 Group sign up Plan in SE Tool By 11:50 am Three students a group if possible Plan in SE Tool By 11 pm Monday Group discussion to agree Each student enters his/her plan