CS 351 Hw3 Sol1

CS 351 Hw3 Sol1 - Safa Erişti Sec03 CS 351 – Homework 3...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Safa Erişti Sec03 CS 351 – Homework 3 Answer 1. 1 Safa Erişti Sec03 Answer 2. HeapSort, unlike other sorting algorithms, can be executed overlapping the input and output. Only I/O time needs to be counted. So the answes is: 2 * b * ebt = 2 * 0.84 * [(400 * 10000000)/2400] 2 * 0.84 *1666666.7 = 2800000ms = 2800seconds. Answer 3. In the previous question we calculated the heap sort, now we need to calculate the merge times and add them together. a)For 2‐way merge time needed for one pass is = 2 * p * nsg * (r+s) + 2 * b *ebt = 2 * 2 * 400 * (24.3) + 2 * 1666666.7 * 0.84 = 2838880 ms We have ceiling[log2(400)] = 9, we have 9 passes, so 9 * 2838880 = 25549920ms and we need to add time on answer 2. Total time is =7.09 hours + 0.78hours = 7.87 hours b) For 4‐way merge time needed for one pass is=2 *4 *400 *(24.3)+2 * 1666666.7 * 0.84 = 2877760ms We have ceiling[log440] = 5, we have 5 passes, so 5 * 2877760 = 3.99 hours 2 Safa Erişti Sec03 We need to add the time on answer two, so the total time is 3.99 + 0.78 = 4.77hours c)For this question P is 400, we can use a specialized formula since only one pass is needed. 4 * ebt * b + 2 * (nsg)2 * (r+s) = 4 * 0.84 * 1666666.7 + 2 * (400)2 * 24.3 = 3.71 hours Answer 4. a) To find 18, 3 disk accesses is required because first access will be to prime area, second access for first entry in the overflow area and on the third access 18 is retrieved. b) For 30, 10 and 32 one disk access is requires, for 27 and 5, two disk access is required and for 18, three disk accesses is required and we have 6 entries. The average number of accesses for successfull search is = 1+1+1+2+2+3/6 = 1.666 c) For entires which have Mod(entry,3) = 0, three disk accesses is required for unsuccessfull search, for entries which have Mod(entry,3)=1, 1 disk access is required and for entries which have Mod(entry,3)=2, 2 disk accesses is required. So (3 + 1 + 2)/3 = 2 Answer 5. Pseudo Key 10 20 3 7 13 14 17 21 25 16 22 30 Key 10 20 3 7 13 14 17 21 25 16 22 30 Pseudo Key In Binary 01010 10100 00011 00111 01101 01110 10001 10101 11001 10000 10110 11110 We start from h=1, Bv=0, Insertions illustrated below. 3 Safa Erişti Sec03 4 Safa Erişti Sec03 Answer 6. For bv=5, h=5; In linear hashing, blocks hashed at level h+1 are: [0,bv‐1] and [2h,n‐1] n being the number of blocks. There are 5 blocks in [0, bv‐1] interval. The other part always has the same quantity. So the blocks hashed at level h+1 is 10. Blocks hashed at level h are in the interval [bv,2h‐1] which is 27. The binary address of the last bucket of the file is 100100. The binary address of the last bucket hashed at level 5 is 11111. For bv=0, h=5; In linear hashing, blocks hashed at level h+1 are: [0,bv‐1] and [2h,n‐1] n being the number of blocks. There are 0 blocks in [0, bv‐1] interval. The other part always has the same quantity. So the blocks hashed at level h+1 is 0. Blocks hashed at level h are in the interval [bv,2h‐1] which is 32. The binary address of the last bucket of the file is obviously 11111. The binary address of the last bucket hashed at level 5 is 11111. Answer 7. Key Value 27 18 29 28 42 13 16 Pseudo Key 5 7 7 6 9 2 5 Binary Pseudo Key 0101 0111 0111 0110 1001 0010 0101 5 Safa Erişti Sec03 6 Safa Erişti Sec03 Answer 8. Key Value 27 42 18 29 28 13 16 Pseudo Key 5 9 7 7 6 2 5 Binary Pseudo Key 0101 1001 0111 0111 0110 0010 0101 7 Safa Erişti Sec03 Directory size does not change, it is 8 for questions 7 and 8. Number of data pages,which is 4, is the same also, because no matter how we put the numbers, entries will go to the same place and table will increase accordingly. 8 ...
View Full Document

This note was uploaded on 12/01/2011 for the course CS 351 taught by Professor Fazlıcan during the Spring '11 term at Bilkent University.

Ask a homework question - tutors are online