CS351 Midterm Exam Solutions

CS351 Midterm Exam Solutions - COMPUTER ENGINEERING...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
COMPUTER ENGINEERING DEPARTMENT Bilkent University CS 351: Data Organization and Management October 27, 2005 – 17:40 – 19:30 NAME: GOOD LUCK! 1 Notes: 1. There are 100 points, 7 questions on 7 pages. 2. Please first READ the questions and provide short answers. 3. Show your work. 4. You are not allowed to use your cell phone or PDA for any purpose. IBM 3380 parameters: When indicated or needed please assume an IBM 3380 like environment with the following parameters. B block size 2400 bytes Bfr no. of records per block 6 btt block transfer time 0.8 ms (data transfer rate is 3000 bytes/ms) ebt effective block transfer time 0.84 ms (effective data transfer rate is 2857 bytes/ms) r average rotational latency time 8.3 ms s average seek time 16 ms 1. (15pts.) Consider a sorted sequential file with an overflow area in an IBM 3380 disk environment. The file contains 300,000 records in the sorted part and 100,000 records in the overflow part. (Take record size as 400 bytes). a. Find the time needed for a successful search. Solution: Let y be the number of blocks in the sorted area, x the number of blocks in the overflow area and b the total number of blocks. A record in the file is in the sorted area with probability y/b and in the overflow area with probability x/b. If the record is in the sorted part, on average we will perform log 2 y-1 disk accesses which totally take the time (log 2 y-1) * (s+r+btt). If the record is in the overflow area, we will first perform a binary search of the whole sorted area and will sequentially search half of the overflow area till we find the record. T f(successful) = y/b * (log 2 y-1) * (s+r+btt) + x/b * [log 2 y * (s+r+btt) + s+r + x/2 * ebt] Setting y = 300,000/6 and x= 100,000/6 (assuming block boundaries overlap): 1 Solutions are due to Pelin Angın.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
T f(successful) = 3 / 4 * 14.6 * 25.1+ 1 / 4 * [15.6 * 25.1 + 24.3 + 8333 * 0.84] = 2128 msec = 2.1 sec. (When logy is used instead of log 2 y as an approximation, the result is 1855 msec, which is very close to the original result.) b. Find the time needed for an unsuccessful search. Solution: In an unsuccessful search, we first perform a binary search in the whole sorted part and then sequentially search the whole overflow part. T f(unsuccessful) = log 2 y * (s+r+btt) + s+r + x * ebt = 15.6 * 25.1 + 24.3 + 16667 * 0.84 = 14416 msec = 14 sec. 2. (15 pts.) Consider the following array representation of a priority queue (i.e., the tree structure used in heap sort): 55, 50, 70, 110, 90, 120 Draw the corresponding priority queue (tree structure). If you see something wrong please explain. Solution: The priority queue corresponding to the given array is: However, the given array (or the tree structure) does not actually represent a priority queue, as the root node has a key value greater than its left child’s (55>50) (Recall that in a priority queue each node has a key
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 12

CS351 Midterm Exam Solutions - COMPUTER ENGINEERING...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online