Click here to load reader

CS3223 Tutorial 3

  • Upload
    aelwen

  • View
    49

  • Download
    0

Embed Size (px)

DESCRIPTION

CS3223 Tutorial 3. Fan Qi [email protected] 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 : - PowerPoint PPT Presentation

Citation preview

CS3223 Tutorial 2

Fan Qi [email protected] Lab 1, com1 #01-08CS3223 Tutorial 3Linear HashLinear HashSortingWhy 2 N ?CPU Cost?MemoryInput 1Input 1Input 1Input 1Input 1Input 1Input 1Input 1Input 1OutputInput 1Input 1Input 1Question 1:023,5,7,11,17, 19,23,0,4,29,33,13,6GetBucket -> Check Split -> Increment next -> Rewind next Question 1:02353,5,7,11,17, 19,23,0,4,29,33,13,6GetBucket -> Check Split -> Increment next -> Rewind next Split & RedistributeQuestion 1:0213573,5,7,11,17, 19,23,0,4,29,33,13,6GetBucket -> Check Split -> Increment next -> Rewind next Split & RedistributeQuestion 1:0013571023,5,7,11,17, 19,23,0,4,29,33,13,6p111GetBucket -> Check Split -> Increment next -> Rewind next Question 1:0013571023,5,7,11,17, 19,23,0,4,29,33,13,6p1111719GetBucket -> Check Split -> Increment next -> Rewind next Split & RedistributeQuestion 1:00015171021137113,5,7,11,17, 19,23,0,4,29,33,13,6p11923GetBucket -> Check Split -> Increment next -> Rewind next Question 1:000401517291021137113,5,7,11,17, 19,23,0,4,29,33,13,6p11923GetBucket -> Check Split -> Increment next -> Rewind next Split & RedistributeQuestion 1:0000015172910211371110043,5,7,11,17, 19,23,0,4,29,33,13,6p11923p233GetBucket -> Check Split -> Increment next -> Rewind next Question 1:00000151729102611371110043,5,7,11,17, 19,23,0,4,29,33,13,6p11923p23313GetBucket -> Check Split -> Increment next -> Rewind next Question 2:0003282401925411710141810301131357111004436Insert 15Question 2:00032824001925411710141810301131357111004436101Insert 15p115Question 2:0003282401925411710141810301131357111004436Delete 44 36Question 2:00328240192541171014181030113135711100 is removedQuestion 2:0003282401925411710141810301131357111004436Minimum Entry to achieve 2 overflow pages in 1 bucketQuestion 2:0003282401925411710141810301131357111004436Minimum Entry to achieve 2 overflow pages in 1 bucketKeep Filling Up Page 11 -> 63, 127,255, 511,1023Question 2:000328240019254117010181011313571110044361011101430Minimum Entry to achieve 2 overflow pages in 1 bucketp163127255511P21023Question 3:006444019255101011311573Minimum insertions to cause all bucket split once ?Question 3:006444019255101011311573Hint: create collisions after splitInsert any element in 11 to split 00 : 63 ( 00001111)Question 3:0006401925510101131157310044Hint: Trying to create collision after splitInsert any two elements in 01 to split 01 : 67( 00111001), 131(0111001)p1163Question 3:0006400192567131101011311573100441015Hint: Trying to create collision after splitInsert any element in 001 to split 10: 41 (00101001)p1163Question 3:00064001925671310101011311573100441015110Hint: Trying to create collision after splitInsert any 4 elements in 000 to split 11: 0, 8, 16, 32p1163p00141Question 3:000640816001925671310101001131004410151101113115763Hint: Trying to create collision after splitp0014163, 67,131, 41, 0, 8, 16,32Question 4 (d):Self-ThinkingHow to write a program to do a K-way merge?Let k = 4Take 4 sorted array, merge them into one sorted arrayAny data structure to use?Thank you!See you next week!