Multilevel Index in form of B trees.
Hashing
Dr. Hussien M.
Sharaf
2
Dr. Hussien M.
Sharaf
3
When an Index gets very big, it can not
be stored in RAM.
It should be stored on file, hence anoth...
Dr. Hussien M.
Sharaf
4
B-tree
Allows searches, insertions, and deletions in
O(Log n) .
The B-tree is a generalization of ...
Dr. Hussien M.
Sharaf
5
B-tree Example
Dr. Hussien M.
Sharaf
6
Adding Records to a B Tree
If global root still have empty slots then place the
new record in sort...
Dr. Hussien M.
Sharaf
7
Adding Records to a B Tree
If current node is full then:
1. Split the leaf node.
2. Place median k...
Dr. Hussien M.
Sharaf
8
Adding Records to a B Tree
If parent node is full then:
1. Split the parent node.
2. keys < middle...
Dr. Hussien M.
Sharaf
9
Example for order = 4
Dr. Hussien M.
Sharaf
10
Inserting X
Dr. Hussien M.
Sharaf
11
Inserting X
Dr. Hussien M.
Sharaf
12
Example of Insertions
Dr. Hussien M.
Sharaf
13
Example for order = 4
Dr. Hussien M.
Sharaf
14
Example for order = 4
Dr. Hussien M.
Sharaf
15
Example for order = 4
Dr. Hussien M.
Sharaf
16
Example for order = 4
Dr. Hussien M.
Sharaf
17
Example for order = 4
Dr. Hussien M.
Sharaf
18
Example for order = 4
Dr. Hussien M.
Sharaf
19
Example for order = 4
Dr. Hussien M.
Sharaf
20
Example for order = 4
Dr. Hussien M.
Sharaf
21
Example for order = 4
Dr. Hussien M.
Sharaf
22
Example for order = 4
Dr. Hussien M.
Sharaf
23
Properties of B trees
Dr. Hussien M. Sharaf 24
A hash table is an effective data structure for
implementing dictionaries.
A dictionary is an abstract data type composed
...
A hash table uses a hash function as an
algorithm to map identifying values, known
as keys (e.g., a person's name), to the...
1. Direct-Address tables.
2. Hash tables.
3. Hash functions.
4. Open addressing.
5. Perfect hashing.
Dr. Hussien M. Sharaf...
CS215 - Lec 10   b trees and hashing
CS215 - Lec 10   b trees and hashing
Upcoming SlideShare
Loading in …5
×

CS215 - Lec 10 b trees and hashing

544 views
470 views

Published on

BTrees and Hashing:
Insert elements into a Btree

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
544
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
41
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

CS215 - Lec 10 b trees and hashing

  1. 1. Multilevel Index in form of B trees. Hashing Dr. Hussien M. Sharaf 2
  2. 2. Dr. Hussien M. Sharaf 3 When an Index gets very big, it can not be stored in RAM. It should be stored on file, hence another level of index that can be loaded into memory is required. Hence we need multilevel of indexing.
  3. 3. Dr. Hussien M. Sharaf 4 B-tree Allows searches, insertions, and deletions in O(Log n) . The B-tree is a generalization of a binary search tree. A Btree of order m is where each node contains (m) keys and (m+1) pointers for children. It is a balanced tree. Each node is a sorted index of keys.
  4. 4. Dr. Hussien M. Sharaf 5 B-tree Example
  5. 5. Dr. Hussien M. Sharaf 6 Adding Records to a B Tree If global root still have empty slots then place the new record in sorted position in the appropriate root node.
  6. 6. Dr. Hussien M. Sharaf 7 Adding Records to a B Tree If current node is full then: 1. Split the leaf node. 2. Place median key in the parent node in sorted order. 3. Records with keys < middle key go to the left leaf node. 4. Records with keys >= middle key go to the right leaf node.
  7. 7. Dr. Hussien M. Sharaf 8 Adding Records to a B Tree If parent node is full then: 1. Split the parent node. 2. keys < middle key go to the left parent node. 3. key s >= middle key go to the right parent node. 4. The median key goes to the next (higher level) index. 5. IF the next level index node is full, continue splitting the index nodes.
  8. 8. Dr. Hussien M. Sharaf 9 Example for order = 4
  9. 9. Dr. Hussien M. Sharaf 10 Inserting X
  10. 10. Dr. Hussien M. Sharaf 11 Inserting X
  11. 11. Dr. Hussien M. Sharaf 12 Example of Insertions
  12. 12. Dr. Hussien M. Sharaf 13 Example for order = 4
  13. 13. Dr. Hussien M. Sharaf 14 Example for order = 4
  14. 14. Dr. Hussien M. Sharaf 15 Example for order = 4
  15. 15. Dr. Hussien M. Sharaf 16 Example for order = 4
  16. 16. Dr. Hussien M. Sharaf 17 Example for order = 4
  17. 17. Dr. Hussien M. Sharaf 18 Example for order = 4
  18. 18. Dr. Hussien M. Sharaf 19 Example for order = 4
  19. 19. Dr. Hussien M. Sharaf 20 Example for order = 4
  20. 20. Dr. Hussien M. Sharaf 21 Example for order = 4
  21. 21. Dr. Hussien M. Sharaf 22 Example for order = 4
  22. 22. Dr. Hussien M. Sharaf 23 Properties of B trees
  23. 23. Dr. Hussien M. Sharaf 24
  24. 24. A hash table is an effective data structure for implementing dictionaries. A dictionary is an abstract data type composed of a collection of (key,value) pairs, such that each possible key appears at most once in the collection. Dr. Hussien M. Sharaf 25
  25. 25. A hash table uses a hash function as an algorithm to map identifying values, known as keys (e.g., a person's name), to their associated values (e.g., their telephone number). Dr. Hussien M. Sharaf 26
  26. 26. 1. Direct-Address tables. 2. Hash tables. 3. Hash functions. 4. Open addressing. 5. Perfect hashing. Dr. Hussien M. Sharaf 27

×