PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation...
Transcript of PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation...
![Page 1: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/1.jpg)
CS 225Data Structures
March 14 – BTree AnalysisWade Fagen-Ulmschneider
![Page 2: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/2.jpg)
BTree AnalysisThe height of the BTree determines maximum number of ____________ possible in search data.
…and the height of the structure is: ______________.
Therefore: The number of seeks is no more than __________.
…suppose we want to prove this!
![Page 3: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/3.jpg)
BTree AnalysisIn our AVL Analysis, we saw finding an upper bound on the height (given n) is the same as finding a lower bound on the nodes (given h).
We want to find a relationship for BTrees between the number of keys (n) and the height (h).
![Page 4: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/4.jpg)
BTree AnalysisStrategy:We will first count the number of nodes, level by level.
Then, we will add the minimum number of keys per node (n).
The minimum number of nodes will tell us the largest possible height (h), allowing us to find an upper-bound on height.
![Page 5: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/5.jpg)
BTree AnalysisThe minimum number of nodes for a BTree of order m at each level:
root:
level 1:
level 2:
level 3:…level h:
![Page 6: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/6.jpg)
BTree AnalysisThe total number of nodes is the sum of all of the levels:
![Page 7: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/7.jpg)
BTree AnalysisThe total number of keys:
![Page 8: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/8.jpg)
BTree AnalysisThe smallest total number of keys is:
So an inequality about n, the total number of keys:
Solving for h, since h is the number of seek operations:
![Page 9: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/9.jpg)
MP4 Animations
![Page 10: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/10.jpg)
MP4 Animations
![Page 11: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/11.jpg)
![Page 12: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/12.jpg)
![Page 13: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/13.jpg)
![Page 14: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/14.jpg)
![Page 15: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/15.jpg)
![Page 16: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/16.jpg)
![Page 17: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/17.jpg)
![Page 18: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/18.jpg)
![Page 19: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/19.jpg)
![Page 20: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/20.jpg)
MP4 Animations
![Page 21: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/21.jpg)
![Page 22: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/22.jpg)
![Page 23: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/23.jpg)
![Page 24: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/24.jpg)
![Page 25: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/25.jpg)
![Page 26: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/26.jpg)
![Page 27: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/27.jpg)
BTree AnalysisGiven m=101, a tree of height h=4 has:
Minimum Keys:
Maximum Keys:
![Page 28: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/28.jpg)
Hashing
![Page 29: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/29.jpg)
HashingGoals: We want to define a keyspace, a (mathematical) description of the keys for a set of data.
…use a function to map the keyspace into a small set of integers.
![Page 30: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/30.jpg)
Hashing
Locker Number Name
103
92
330
46
124
![Page 31: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/31.jpg)
Hashing
Hash function
…
![Page 32: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/32.jpg)
A Hash Table based Dictionary
A Hash Table consists of three things:1.
2.
3.
Dictionary<KeyType, ValueType> d;
d[k] = v;
1
2
Client Code:
![Page 33: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/33.jpg)
A Perfect Hash Function
(Angrave, CS 241)(Beckman, CS 421)(Cunningham, CS 210)(Davis, CS 101)(Evans, CS 126)(Fagen-Ulmschneider, CS 225)(Gunter, CS 422)(Herman, CS 233)
Hash function
Key Value
![Page 34: PowerPoint Presentation · 103 92 330 46 124. Hashing Hash function ... PowerPoint Presentation Author: Wade Fagen Created Date: 3/14/2018 10:23:07 AM ...](https://reader036.fdocuments.in/reader036/viewer/2022071213/604187c15ea79f57a558b306/html5/thumbnails/34.jpg)
A Perfect Hash Function
Hash function
Key Value
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Keyspace:Rolling 5 dice!