The first in-term exam will cover chapters 1-4 (Introduction, Arrays, Records, Simple Linked Lists, Stacks and Queues, and Linear Structures.) Here is a sample test for CS 3100. Answers are included. This should give you an idea of the kind of things I expect you to know. I don't use the form of these questions as much as I used to -- I use more multiple choice and true-false now. COMPUTER SCIENCE 3100 DATA STRUCTURES Sarraille MIDTERM TEST KEY DIRECTONS: Answer the questions as COMPLETELY as you can, with the details you remember, but be CONCISE. Tell me what you DO know, even when you do not remember everything. No "Padding", please. 1. DEFINE: Data Type. ANSWER: A data type is a set of values together with a set of operations on those values. 2. DEFINE: Abstract Data Structure. ANSWER: A data structure is a data type whose values are composed of component elements that are related by some structure. An abstract data structure is a data structure that exists as a product of our imagination, and concentrates on the essential properties of the data structure, ignoring implementation constraints and details. 3. Name some of the advantages of abstract data typing and information hiding. ANSWER: precise specifications, modularity, simplicity, integrity, and implementation independence. 4. What is it about the usual implementation of arrays that justifies calling arrays "random access" data structures? ANSWER: The usual implementations of arrays provide that each component can be accessed by index position in equal time, independent of the particular position of the element in the array, and independent of the total number of elements in the array. 5. What is "dynamic memory allocation"? Give a high level description of how it works. ANSWER: Dynamic memory allocation is a system of management of computer memory in which memory space for computation is given to the program only when actually needed, only in the exact amount needed, and is recycled as soon as it is no longer in use. A pool of available memory space is maintained by the run-time system. When a request for memory is made by a running program (process) the request is served from the pool. When memory space is ready to be recycled, the process makes a request to the run-time system to return it to the pool. 6. What is a multi-linked list? Name an application of such a structure. ANSWER: A multi-linked list is a linked list that is simultaneously kept in two or more different logical orders by use of (respectively) two or more sets of pointers. Storing records of library books simultaneously ordered by title, author, and subject is one application. 7. What are the disadvantages to implementing a stack as an array? ANSWER: Under the usual conditions in force when implementing a stack as an array, the stack is limited in size to whatever the declared size of the array is, and the entire array is reserved for use as the stack, even when the stack contains only very few elements. 8. There are certain problems associated with implementing a FIFO queue as an array. I am talking about problems that do NOT arise in connection with implementing a stack as an array. How are these problems solved by the queue array implementation given in our text? ANSWER: The queue can "crawl" to one end of the array if all the elements are not shifted after each deletion. This can lead to an inability to add more elements to the queue, even when there are many empty cells in the array. The solution to this problem is to make the queue "logically" circular, by letting the queue "wrap" back around to the beginning of the array after it reaches the far end. This creates another problem, however, in that it becomes difficult to devise tests for determining when the queue is empty or full -- it is hard to distinguish a full queue from an empty queue. This latter problem is solved in our text (partly) by making the pointer to the head of the list actually point to the position in the array BEFORE the position containing the first element in the queue. 9. In our text, what are the disadvantages of the array implementation of a priority queue which do NOT arise in connection with the array implementations of ordinary stacks and queues? ANSWER: There is no practical method of avoiding having to shift the elements of the priority queue when enqueueing. When enqueueing, a search has to be done to find the proper location to make the insertion. (You can avoid this by always inserting in the front, but then the queue is not going to be ordered by priority, and search will have to be done to find the highest priority element when serving.) 10. Explain how a FIFO strategy of disk scheduling can be "unfair to everyone while attempting to be fair to everyone". ANSWER: It takes time for the disk arm to move from one track to another. If the requests for disk operations are serviced without regard to the location of the disk arm, the average time it takes to position the arm and service a request can be very great. If a disk scheduling policy is used which tries to service requests in the immediate vicinity of the arm first, then the average serve time can be reduced, thus making the server appear faster to all users.