Eastern Mediterranean University Department of Computer Engineering CMPE 352 - Midterm Exam 2001 – 2002 Summer School 16 August 2002 Name, Surname Student No Group No :………………….. :………………….. :………………….. Instructor: Visit. Assoc. Prof. Alexander CHEFRANOV Duration: 2 Hours INSTRUCTIONS: 1. Please answer all questions. 2. Do not ask any question to the invigilator. 3. GSM phones should be turned off. Questions I II-1 II-2 II-3 II-4 Total GOOD LUCK! 1 Marks PART 1: Storage and File Sructure, Query Processing and Optimization (3 points each question) 1) Number (in the boxes) the following memory types according to read access time in ascending order: 4 5 3 2 1 2) floppy dısks magnetıc tapes hard dısks flash memory cache memory Cylinders of a magnetic disk were introduced because of: a) the large disks capacity b) placing magnetic heads on the common arm c) placing magnetic platters on the common spindle d) large rotational speed of the magnetic platters e) none of the above 3) Rotational latency is a time required to find a) a disk b) a head c) a cylinder d) a sector e) none of the above 4) RAID level 0 organization reduces a) rotational speed b) queries execution time c) rotational latency d) number of disk block accesses e) none of the above 5) MRU buffer management algorithm assumes to replace the page which a) was most frequently used b) was most randomly used c) was not used for the most time d) was used the last before the current moment e) none of the above 2 6) To insert new tuple in the fixed-length records file with preservation of tuples ordering according to some key there must be maintained a) a list of attributes; b) a linked list of existing tuples; c) a linked list of deleted tuples; d) a linked list of pointers e) nothing of the above 7) Hardware swizzling of persistent pointers assumes using of a) volatile memory; b) virtual memory; c) tertiary memory; d) cache memory e) none of the above 8) Assume that we have a clustering index on the A attribute of the r(A,B,C) relation. Which of the following is necessarily correct? a) A is a candidate key of r b) A is a superkey key of r c) t1(A) < t2(A) -> t1 precedes t2 in r, where t1, t2 are tuples of r,t1(A), t1(A) are the values of field A in the tuples, -> sign of implication d) index must be sparse e) none of the above 9) Assume that we have a secondary index on the A attribute of the r(A,B,C) relation. Which of the following is necessarily correct? a) the index is clustering b) the index is sparse c) the index is ordered d) the index is dense e) none of the above 3 For questions 10 - 13, assume that r(A,B,C), s(C,D) are relations. Let the number of tuples in r be 300, the number of tuples in s be 600. A block on disk can hold 30 records of r and 25 records of s. 10) What is the number of records in r |><| s (r natural join s) if C is a foreign key in s for r? a) 300 b) 600 c) 900 d) 1200 e) other value: 11) What is a good estimate of the number of records in r |><| s (r natural join s) if C is not a key of r and C is not a key of s? Assume that there are 10 distinct C values in r and 20 distinct C values in s. a) 30 x 600 b) 20 x 600 c) 15 x 600 d) 10 x 60 e) other value: 12) How many block accesses are needed to compute a natural join r |><| s, if r is traversed in the outer loop of the block-nested loop join and memory size M=10 (can accommodate 10 disk blocks)? a) 10 + 10x24 b) 24+24x10 c) 10+2x24 d) 24 + 3x10 e) other value: 13) How many block accesses are needed to compute the join r |><| s, if s is traversed in the outer loop of the nested loop join and memory size M=15 (can accommodate 15 disk blocks)? a) 24+600x10 b) 10+300x24 c) 24 + 2x10 d) 24 + 10 e) other value: 4 14) Assume that we have 7 blocks of memory available for the hash join operation. In how many steps can we partition a relation that occupies 100 blocks on disk such that it can be the build input of the partition operation ? a) 4 b) 3 c) 2 d) 1 e) other value: 15) Assume that we have 5 blocks of memory available for the merge-sort operation. How many block accesses do we need to merge-sort a relation which occupies 111 blocks? Assume we also write back the result of the sort operation. a) 111 x 2 x 3 b) 111 x 2 x 4 c) 111 x 2 x 5 d) (111 4) x 3 x 2 e) other value: 5 PART II: Indexing and Hashing II-1) Assume that each disk block can hold 2 records and hash function h(x) = (x mod 10) is represented by 4 binary digits. For example, h(16)= 0110, h(2)=0010, h(31)=0001 etc. Assuming that we use extendable hashing, show the hash structure after the insertion of 29 28 16 12 19 11 in the given order. Make sure you label the blocks with the number of bits used. We need to see the hash structure after each insertion. (15 pts) 0 0 29 28 1 1 1 0 1 16 12 29 28 2 00 01 1 16 12 10 11 3 000 001 010 011 100 16 12 29 28 3 2 111 29 28 2 4 2 0000 12 11 4 0001 0010 0011 29 0100 16 1 4 0000 0001 0010 0011 0100 16 12 28 0101 0110 0111 1000 1001 0101 0110 0111 1000 100 101 110 1 101 110 2 4 1001 1010 1011 3 3 1010 1011 1100 2 1101 1110 1111 111 6 2 4 28 4 3 29 19 2 Assume in the questions below that tuples of the following relation r(A) with only one attribute A appear in the given sequence r(A)=(3,2,11,14,41,12,33,25,76,5,16,8). II-2) An incomplete 2-level ordered secondary index on A for r(A) with 3 entries in the 2nd level is given below. Complete this structure by filling in the blank cells in the first and 2nd level indices, assuming that numeration of tuples starts from 1 (10 pts). Tuples of r(A): A 3 2 11 14 41 12 33 25 76 5 16 8 Record № 1 2 3 4 5 6 7 8 9 10 11 12 1st level index Ref 2 Key value Record № 1 10 12 3 2 3 5 8 1 2 3 4 2nd level index Ref Key value Record № 7 4 4 8 7 5 9 11 12 14 25 33 41 76 5 7 8 9 10 11 10 8 14 41 1 2 3 7 6 6 II-3) An incomplete B+-tree is given below for r(A) with n=4. Each node is uniquely identified by its number (below node, at right). Pointers to tuples in leaf nodes are omitted for brevity. a. Complete this structure up to full B+-tree using arrows and filling values in appropriate places (10 pts). | 14 | | | | | 1 | 5 | | 11 | | | 33 | | | | 3 2 |2| |3| | | 4 |5 | | 8| | | |11| |12| | | 5 6 |14| |16| |25| | 7 |33| |41| |76 | b. Write out the sequence of B+-tree nodes numbers, passed by while processing query SELECT * FROM r WHERE A >= 4 and A<=15 (5 pts). (1, 2, 4, 5, 6, 7) 8 8 II-4) An incomplete schema reflecting the process of sorting r(A) using the external sortmerge algorithm is given below, assuming that memory buffer has only 3 pages, each of which can hold only 1 tuple (so, number of pages for r(A) is 12). Complete this schema by drawing the necessary frames, filling them by appropriate values and connecting them by appropriate arrows (15 pts). 2 3 11 3 2 11 12 14 14 41 2 3 11 12 14 41 41 12 3 5 8 11 12 33 25 25 76 33 76 5 16 8 2 5 8 5 8 16 25 33 76 16 *************************** The End **************************** 9 14 16 25 33 41 76