1Master of Computer Engineering Chiangmai University.

Slides:



Advertisements
Similar presentations
© 2004 Goodrich, Tamassia Hash Tables
Advertisements

1 Designing Hash Tables Sections 5.3, 5.4, Designing a hash table 1.Hash function: establishing a key with an indexed location in a hash table.
CS 11 C track: lecture 7 Last week: structs, typedef, linked lists This week: hash tables more on the C preprocessor extern const.
An Introduction to Hashing. By: Sara Kennedy Presented: November 1, 2002.
Lecture 6 : Dynamic Hashing Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University.
© 2004 Goodrich, Tamassia Hash Tables1  
© 2004 Goodrich, Tamassia Dictionaries   
© 2004 Goodrich, Tamassia Maps1. © 2004 Goodrich, Tamassia Maps2 A map models a searchable collection of key-value entries The main operations of a map.
Dictionaries1 © 2010 Goodrich, Tamassia m l h m l h m l.
Maps. Hash Tables. Dictionaries. 2 CPSC 3200 University of Tennessee at Chattanooga – Summer 2013 © 2010 Goodrich, Tamassia.
Data Structures Lecture 12 Fang Yu Department of Management Information Systems National Chengchi University Fall 2010.
TTIT33 Algorithms and Optimization – Lecture 5 Algorithms Jan Maluszynski - HT TTIT33 – Algorithms and optimization Lecture 5 Algorithms ADT Map,
Maps, Dictionaries, Hashtables
© 2004 Goodrich, Tamassia Maps1. © 2004 Goodrich, Tamassia Maps2 A map models a searchable collection of key-value entries The main operations of a map.
Chapter 5: Hashing Hash Tables
Hash Tables1 Part E Hash Tables  
Hash Tables1 Part E Hash Tables  
Hash Tables1 Part E Hash Tables  
COMP 171 Data Structures and Algorithms Tutorial 10 Hash Tables.
Data Structures Hash Table (aka Dictionary) i206 Fall 2010 John Chuang Some slides adapted from Marti Hearst, Brian Hayes, Andreas Veneris, Glenn Brookshear,
CSE 373 Data Structures and Algorithms Lecture 18: Hashing III.
Aree Teeraparbseree, Ph.D
Dictionaries 4/17/2017 3:23 PM Hash Tables  
Introducing Hashing Chapter 21 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Maps, Hash Tables and Dictionaries Chapter 10.1, 10.2, 10.3, 10.5.
Maps A map is an object that maps keys to values Each key can map to at most one value, and a map cannot contain duplicate keys KeyValue Map Examples Dictionaries:
A Level Computer Science Topic 9: Data Structures T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen.
CS212: DATA STRUCTURES Lecture 10:Hashing 1. Outline 2  Map Abstract Data type  Map Abstract Data type methods  What is hash  Hash tables  Bucket.
D ESIGN & A NALYSIS OF A LGORITHM 07 – M AP Informatics Department Parahyangan Catholic University.
Hash Tables1   © 2010 Goodrich, Tamassia.
Maps, Hash Tables, Skip Lists, Sets last Update: Nov 4, 2014 EECS2011: Maps, Hash Tables, Skip Lists, Sets1.
Hashing Hashing is another method for sorting and searching data.
© 2004 Goodrich, Tamassia Hash Tables1  
LECTURE 35: COLLISIONS CSC 212 – Data Structures.
Author: Takdir, S.ST. © Sekolah Tinggi Ilmu Statistik.
CSC 212 – Data Structures Lecture 26: Hash Tables.
ITEC 109 Lecture 22 Ways to use lists. Review Lists –Copying / Pass by reference.
CHAPTER 9 HASH TABLES, MAPS, AND SKIP LISTS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++,
Map ADT by Dr. Bun Yue Professor of Computer Science CSCI 3333 Data Structures.
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.
CSE 373: Data Structures and Algorithms Lecture 16: Hashing III 1.
CSE 143 Lecture 11: Sets and Maps reading:
Maps1 © 2010 Goodrich, Tamassia. Maps2  A map models a searchable collection of key-value entries  The main operations of a map are for searching, inserting,
© 2004 Goodrich, Tamassia Maps1. © 2004 Goodrich, Tamassia Maps2 A map models a searchable collection of key-value entries The main operations of a map.
CSC 212 – Data Structures Lecture 28: More Hash and Dictionaries.
Lecture14: Hashing Bohyung Han CSE, POSTECH CSED233: Data Structures (2014F)
Binary Search Trees Chapter 7 Objectives
Maps Rem Collier Room A1.02 School of Computer Science and Informatics
Design & Analysis of Algorithm Map
Doubly Linked Lists 6/3/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Hash Tables 6/13/2018 Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015 Cuckoo Hashing.
Hashing CSE 2011 Winter July 2018.
© 2013 Goodrich, Tamassia, Goldwasser
Hash Tables 3/25/15 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M.
JCF Hashmap & Hashset Winter 2005 CS-2851 Dr. Mark L. Hornick.
Data Structures Maps and Hash.
Dictionaries 11/23/2018 5:34 PM Hash Tables   Hash Tables.
Maps.
Hash Tables   Maps Dictionaries 12/7/2018 5:58 AM Hash Tables  
Ordered Maps & Dictionaries
Computer Science — An Overview J. Glenn Brookshear
Copyright © Aiman Hanna All rights reserved
"He's off the map!" - Eternal Sunshine of the Spotless Mind
Dictionaries 1/17/2019 7:55 AM Hash Tables   4
Problem Understanding
Dictionaries 4/5/2019 1:49 AM Hash Tables  
CS210- Lecture 16 July 11, 2005 Agenda Maps and Dictionaries Map ADT
CS210- Lecture 15 July 7, 2005 Agenda Median Heaps Adaptable PQ
Figure:
Problem Understanding
Presentation transcript:

1Master of Computer Engineering Chiangmai University

2

3 Array salary index We can build to platform ( php code ) $salary[i] = ? EX. $salary[1] = $salary[3] = But we can’t know. Who’s salary ?

4Master of Computer Engineering Chiangmai University Array salary Sara Bob Smith John Steve Sara Bob Smith John Steve name We can build to platform ( php code ) $salary[‘name’] = ? EX. $salary[‘Smith’] = We can replace index by name

5Master of Computer Engineering Chiangmai University

6

7

8

9 trailer header nodes/positions entries Sara 11000

10Master of Computer Engineering Chiangmai University trailer header nodes/positions entries Sara Bob Bob 12000

11Master of Computer Engineering Chiangmai University trailer header nodes/positions entries Sara Bob Bob Smith 15000

12Master of Computer Engineering Chiangmai University trailer header nodes/positions entries Sara Bob Bob Smith Steve Steve 18000

13Master of Computer Engineering Chiangmai University trailer header nodes/positions entries Sara Bob Bob Smith Steve Steve

14Master of Computer Engineering Chiangmai University trailer header nodes/positions entries Sara Bob Bob Smith Steve Steve 18000

15Master of Computer Engineering Chiangmai University trailer header nodes/positions entries Sara Bob Bob Smith Steve Steve 18000

16Master of Computer Engineering Chiangmai University trailer header nodes/positions entries Sara Bob Bob Smith Steve Steve 18000

17Master of Computer Engineering Chiangmai University trailer header nodes/positions entries Sara Smith Steve 18000

18Master of Computer Engineering Chiangmai University

19Master of Computer Engineering Chiangmai University

20Master of Computer Engineering Chiangmai University

21Master of Computer Engineering Chiangmai University String Key StringString Hash Code CompressionFunctionCompressionFunction Hash Function Hash Table Addr.Addr.KeyKeyDataData

22Master of Computer Engineering Chiangmai University Figure Reference :

23Master of Computer Engineering Chiangmai University Algorithm get(k): Output: The value associated with the key k in the map, or null if there is no entry with key equal to k in the map return B[h(k)].get(k) {delegate the get to the list-based map at B[h(k)]} Algorithm put(k,v): Output: If there is an existing entry in our map with key equal to k, then we return its value (replacing it with v); otherwise, we return null t = B[h(k)].put(k,v) {delegate the put to the list-based map at B[h(k)]} if t = null then {k is a new key } n = n + 1 return t

24Master of Computer Engineering Chiangmai University Algorithm remove(k): Output: The (removed) value associated with key k in the map, or null if there is no entry with key equal to k in the map t = B[h(k)].remove(k) {delegate the remove to the list-based map at B[h(k)]} if t ≠ null then {k was found} n = n - 1 return t

25Master of Computer Engineering Chiangmai University

26Master of Computer Engineering Chiangmai University

27Master of Computer Engineering Chiangmai University

28Master of Computer Engineering Chiangmai University Figure Reference :

Pseudo-code for Insert: 29Master of Computer Engineering Chiangmai University

30Master of Computer Engineering Chiangmai University Algorithm preOrder(v) visit(v) for each child w of v preorder (w) Algorithm preOrder(v) visit(v) for each child w of v preorder (w)

31Master of Computer Engineering Chiangmai University

32Master of Computer Engineering Chiangmai University

33Master of Computer Engineering Chiangmai University

34Master of Computer Engineering Chiangmai University

35Master of Computer Engineering Chiangmai University

36Master of Computer Engineering Chiangmai University

37Master of Computer Engineering Chiangmai University

38Master of Computer Engineering Chiangmai University

39Master of Computer Engineering Chiangmai University

40Master of Computer Engineering Chiangmai University

41Master of Computer Engineering Chiangmai University

42Master of Computer Engineering Chiangmai University

43Master of Computer Engineering Chiangmai University

44Master of Computer Engineering Chiangmai University

45Master of Computer Engineering Chiangmai University

46Master of Computer Engineering Chiangmai University

47Master of Computer Engineering Chiangmai University

48Master of Computer Engineering Chiangmai University * d = size of alphabet m = size of the string parameter of the operation m = size of the string parameter of the operation

49Master of Computer Engineering Chiangmai University