



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Midterm w/ answers Material Type: Exam; Class: Data Structures and File Mgmt; Subject: Computer Science; University: Virginia Polytechnic Institute And State University; Term: Spring 1999;
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Spring 1999 1:00 MWF
VI
RG
IN
IA
PO LYTECHNICI NS TI TU TE AN D ST A (^) TE UNIVER SI U T TY PROSIM
Instructions:
Pledge: On my honor, I have neither given nor received unauthorized aid on this examination.
Spring 1999 1:00 MWF
1) (a) [8 points] Define the overhead fraction F for a data structure implementation.
(b) [8 points] Sketch the left child/right sibling data structure for representing the tree given below. Assume that parent pointers are used and list the nodes in alphabetical order.
(c) [8 points] Calculate the overhead fraction F for the left child/right sibling general tree implementation, for a tree containing a total of N nodes. Assume parent pointers are used, that the data value stored in each node occupies D bytes, and that an integer index occupies X bytes.
Spring 1999 1:00 MWF
4) Consider the following "sorting" problem. You are given a collection of n bolts and n nuts. For each bolt in the collection, there is at least one nut of the same size (and so for each nut, there is at least one bolt on which it will fit). You do not know, initially, which nut matches which bolt. Furthermore, the differences in size between two nuts or two bolts may be too small to detect visually; so the only way to compare sizes is to attempt to screw a particular nut onto a particular bolt, which may reveal that the nut is too small for the bolt, just right, or too large. Attempting to screw a nut onto a bolt is a constant-time operation.
(a) [10 points] Describe an efficient algorithm for matching all the nuts with corresponding bolts. Your description does not have to be in pseudocode, but it must be clear and complete.
(b) [10 points] For the best possible algorithm in part (a), what is big-O for the number of comparisons that would be required in the best case? Justify your answer.
Spring 1999 1:00 MWF
5) [12 points] Recall the physical geometry of a disk system. For each of the options listed below (which do not change the total capacity of the disk), determine the effect that option would have on the indicated timing (none, increase, decrease). Consider only the physical operation of the device, disregarding cost of logic operations in the disk controller.
Option Seek time Latency time Transfer time Double the number of platters and halve the number of tracks per platter.
Double the number of tracks per platter, keeping the same track spacing and halving the number of platters.
6) [12 points] For each of the following protocols for a self-organizing list, state clearly one situation in which the protocol would be less effective than desirable, or even counterproductive, and explain why.
(a) move-to-front
(b) order by access count