Min Chen School of Computer Science and Engineering Seoul National University Data Structure: Chapter 10.

Slides:



Advertisements
Similar presentations
Hash Tables CSC220 Winter What is strength of b-tree? Can we make an array to be as fast search and insert as B-tree and LL?
Advertisements

Introduction to Algorithms
Part II Chapter 8 Hashing Introduction Consider we may perform insertion, searching and deletion on a dictionary (symbol table). Array Linked list Tree.
Dictionaries Again Collection of pairs.  (key, element)  Pairs have different keys. Operations.  Search(theKey)  Delete(theKey)  Insert(theKey, theElement)
Theory I Algorithm Design and Analysis (5 Hashing) Prof. Th. Ottmann.
File Processing : Hash 2015, Spring Pusan National University Ki-Joune Li.
Hashing as a Dictionary Implementation
Dictionaries Collection of pairs.  (key, element)  Pairs have different keys. Operations.  get(theKey)  put(theKey, theElement)  remove(theKey) 5/2/20151.
Hashing Chapters What is Hashing? A technique that determines an index or location for storage of an item in a data structure The hash function.
Using arrays – Example 2: names as keys How do we map strings to integers? One way is to convert each letter to a number, either by mapping them to 0-25.
HashMaps. Overview What are HashMaps? Implementing DictionaryADT with HashMaps HashMaps 2/16.
Data Management and File Organization
Maps, Dictionaries, Hashtables
1 Hashing (Walls & Mirrors - end of Chapter 12). 2 I hate quotations. Tell me what you know. – Ralph Waldo Emerson.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 48 Hashing.
Sets and Maps Chapter 9. Chapter 9: Sets and Maps2 Chapter Objectives To understand the Java Map and Set interfaces and how to use them To learn about.
Chapter 5: Hashing Hash Tables
CS 206 Introduction to Computer Science II 11 / 12 / 2008 Instructor: Michael Eckmann.
Aree Teeraparbseree, Ph.D
Introducing Hashing Chapter 21 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
1. 2 Problem RT&T is a large phone company, and they want to provide enhanced caller ID capability: –given a phone number, return the caller’s name –phone.
CS2110 Recitation Week 8. Hashing Hashing: An implementation of a set. It provides O(1) expected time for set operations Set operations Make the set empty.
(c) University of Washingtonhashing-1 CSC 143 Java Hashing Set Implementation via Hashing.
Min Chen School of Computer Science and Engineering Seoul National University Data Structure: Chapter 7.
TEMPLATE DESIGN © Haha  SSAHA Kelvin Gu, Tiffany Lin, Nick Altemose, Kevin Tao Duke University, Trinity College of Arts.
CS 202, Spring 2003 Fundamental Structures of Computer Science II Bilkent University1 Hashing CS 202 – Fundamental Structures of Computer Science II Bilkent.
Final Review Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Chapter 5: Hashing Collision Resolution: Separate Chaining Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
CS 61B Data Structures and Programming Methodology July 17, 2008 David Sun.
LECTURE 34: MAPS & HASH CSC 212 – Data Structures.
1 5. Abstract Data Structures & Algorithms 5.2 Static Data Structures.
Prof. Amr Goneid, AUC1 CSCI 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 5. Dictionaries(2): Hash Tables.
AITI Lecture 20 Hashing Adapted from MIT Course 1.00 Spring 2003 Lecture 31 (Teachers: Please do not erase the above note)
Hashing as a Dictionary Implementation Chapter 19.
1 Introduction to Hashing - Hash Functions Sections 5.1, 5.2, and 5.6.
Chapter 5: Hashing Part I - Hash Tables. Hashing  What is Hashing?  Direct Access Tables  Hash Tables 2.
Chapter 10 Hashing. The search time of each algorithm depend on the number n of elements of the collection S of the data. A searching technique called.
Chapter 11 Hash Tables © John Urrutia 2014, All Rights Reserved1.
Author: Takdir, S.ST. © Sekolah Tinggi Ilmu Statistik.
Hashing is a method to store data in an array so that sorting, searching, inserting and deleting data is fast. For this every record needs unique key.
1 Improving search performance: Hash tables Instructor: Mainak Chaudhuri
“Never doubt that a small group of thoughtful, committed people can change the world. Indeed, it is the only thing that ever has.” – Margaret Meade Thought.
Building Java Programs Bonus Slides Hashing. 2 Recall: ADTs (11.1) abstract data type (ADT): A specification of a collection of data and the operations.
1 Chapter 7 Skip Lists and Hashing Part 2: Hashing.
Hashing Suppose we want to search for a data item in a huge data record tables How long will it take? – It depends on the data structure – (unsorted) linked.
COSC 1030 Lecture 10 Hash Table. Topics Table Hash Concept Hash Function Resolve collision Complexity Analysis.
Chapter 13 C Advanced Implementations of Tables – Hash Tables.
CHAPTER 9 HASH TABLES, MAPS, AND SKIP LISTS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++,
Searching Tables Table: sequence of (key,information) pairs (key,information) pair is a record key uniquely identifies information, so no duplicate records.
Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight.
Sets and Maps Chapter 9. Chapter Objectives  To understand the Java Map and Set interfaces and how to use them  To learn about hash coding and its use.
Building Java Programs Generics, hashing reading: 18.1.
Chapter 27 Hashing Jung Soo (Sue) Lim Cal State LA.
COMP 53 – Week Eleven Hashtables.
School of Computer Science and Engineering
Efficiency add remove find unsorted array O(1) O(n) sorted array
Hash table another data structure for implementing a map or a set
Chapter 28 Hashing.
Building Java Programs
Chapter 21 Hashing: Implementing Dictionaries and Sets
slides created by Marty Stepp and Hélène Martin
CSE 373: Data Structures and Algorithms
slides adapted from Marty Stepp and Hélène Martin
CSE 373 Data Structures and Algorithms
CSE 373: Data Structures and Algorithms
2018, Spring Pusan National University Ki-Joune Li
Podcast Ch21a Title: Hash Functions
slides created by Marty Stepp and Hélène Martin
Chapter 5: Hashing Hash Tables
Presentation transcript:

Min Chen School of Computer Science and Engineering Seoul National University Data Structure: Chapter 10

 Analogy of Hash Tables  Definition of Hash Table  Visualization of Hash Table  Problem in Hash Table  Chaining Keys in Hash Table  Compress Function Design

 Word and Definition  Word is a key that addresses the definition  Number of keys: ▪ 26×26=676  Map the word to a list of integer will increase the searching process

Public Class Word { public static final int LETTER=26; public static final int WORDS= LETTER* LETTER; private String word; public int hashCode() { return LETTERS*(word.charAt(0)-’a’)+ (word.charAt(1)-’a’); }

Public Class Dictonary { private Definition[] defTable = new Definition[Word.WORDS]; public void insert(Word w, Definition d) { defTable[w.hashCode()]=d; } public Definition find(Word w) { return defTable[w.hashCode()]; } If Maximum length of words is 45 characters, we need length to store the keys

 A hash table or hash map is a data structure that uses a hash function to efficiently map certain identifiers or keys to associated values.

 n: number of keys(words) stored  Table of N buckets: N is a bit larger than n  A hash table maps huge set of possible keys into N buckets by applying a compression function to each hash code …… Buckets N …… n

 Redundant buckets  If the compress function is not well designed, there may be many redundant buckets in the table  Collision  In order to decrease the size of the table, the compress function may lead several keys hash to a same bucket  Solution: Chaining Keys

Compress Function

 How to design a good compress function?