1 / 29

CS3223 Tutorial 3

CS3223 Tutorial 3. Fan Qi fan.qi@nus.edu.sg Database Lab 1, com1 #01-08. Linear Hash. Parameters: Level: indicates the rounds of splitting Initial hash size: buckets Next: next buckets to be split Notations: Bucket : Hash size at beginning of round :

aelwen
Download Presentation

CS3223 Tutorial 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS3223 Tutorial 3 Fan Qi fan.qi@nus.edu.sg Database Lab 1, com1 #01-08

  2. Linear Hash • Parameters: • Level: indicates the rounds of splitting • Initial hash size: buckets • Next: next buckets to be split • Notations: • Bucket : • Hash size at beginning of round : • Hash function in round : • Properties: • Split Image of :

  3. Linear Hash • Basic operations: • GetBucketNumber() • SplitBucket() • GetBucketNumber(k) • 1. Check the range of • 2. Use if • SplitBucket(): • 1. Split and Redistribution • 2. Increment next • 3. Rewind next if necessary

  4. Sorting Why 2 N ? • External Sorting: • A variant of Merge Sort • B-1 way Merge Sort: CPU Cost? Memory Input 1 Input 1 Input 1 Input 1 Input 1 Input 1 Input 1 Input 1 Output Input 1 Input 1 Input 1 Input 1

  5. Question 1: 3,5,7,11,17, 19,23,0,4,29,33,13,6 GetBucket -> Check Split -> Increment next -> Rewind next

  6. Question 1: 3,5,7,11,17, 19,23,0,4,29,33,13,6 Split & Redistribute GetBucket -> Check Split -> Increment next -> Rewind next

  7. Question 1: 3,5,7,11,17, 19,23,0,4,29,33,13,6 Split & Redistribute GetBucket -> Check Split -> Increment next -> Rewind next

  8. Question 1: 3,5,7,11,17, 19,23,0,4,29,33,13,6 GetBucket -> Check Split -> Increment next -> Rewind next

  9. Question 1: 3,5,7,11,17, 19,23,0,4,29,33,13,6 Split & Redistribute GetBucket -> Check Split -> Increment next -> Rewind next

  10. Question 1: 3,5,7,11,17, 19,23,0,4,29,33,13,6 GetBucket -> Check Split -> Increment next -> Rewind next

  11. Question 1: 3,5,7,11,17, 19,23,0,4,29,33,13,6 Split & Redistribute GetBucket -> Check Split -> Increment next -> Rewind next

  12. Question 1: 3,5,7,11,17, 19,23,0,4,29,33,13,6 GetBucket -> Check Split -> Increment next -> Rewind next

  13. Question 1: 3,5,7,11,17, 19,23,0,4,29,33,13,6 GetBucket -> Check Split -> Increment next -> Rewind next

  14. Question 2: Insert 15

  15. Question 2: Insert 15

  16. Question 2: Delete 44 36

  17. Question 2: 100 is removed

  18. Question 2: Minimum Entry to achieve 2 overflow pages in 1 bucket

  19. Question 2: Minimum Entry to achieve 2 overflow pages in 1 bucket Keep Filling Up Page 11 -> 63, 127,255, 511,1023

  20. Question 2: Minimum Entry to achieve 2 overflow pages in 1 bucket

  21. Question 3: Minimum insertions to cause all bucket split once ?

  22. Question 3: Hint: create collisions after split Insert any element in 11to split 00 : 63 ( 00001111)

  23. Question 3: Hint: Trying to create collision after split Insert any two elements in 01 to split 01 : 67( 00111001), 131(0111001)

  24. Question 3: Hint: Trying to create collision after split Insert any element in 001 to split 10: 41 (00101001)

  25. Question 3: Hint: Trying to create collision after split Insert any 4 elements in 000 to split 11: 0, 8, 16, 32

  26. Question 3: Hint: Trying to create collision after split 63, 67,131, 41, 0, 8, 16,32

  27. Question 4 (d): • Pass 0: runs are produced. • Pass 1: Merge all runs therefore, • Take the integer of B

  28. Self-Thinking • How to write a program to do a K-way merge? • Let k = 4 • Take 4 sorted array, merge them into one sorted array • Any data structure to use?

  29. Thank you! See you next week!

More Related