



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
The instructions and questions for test 1 of the cs 2606 data structures and object-oriented development ii course. The test covers topics such as big o notation, binary search trees, matrix operations, and buffer pools. Students are required to answer short-answer questions and are not allowed to use laptops, calculators, or other electronic devices during the examination.
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Name (Last, First) printed
Pledge: On my honor, I have neither given nor received unauthorized aid on this examination.
signed
a) [10 points] What does the first fact given above imply regarding any big-Ο, big-Ω and/or big-Θ relationships between the functions? Be complete. No justifications are needed.
By definition, f(n) is Ω(g(n)). If we divide through the inequality by 3, the resulting inequality implies that g(n) is O(f(n)).
b) [10 points] What does the second fact given above imply regarding any big-Ο, big-Ω and/or big-Θ relationships between the functions? Be complete. No justifications are needed.
Since the second fact only implies that certain bounds apply for a finite range of values of n, no conclusions about O, Ω, or Θ follow from it.
Here is a minimal implementation:
template
class nodeWithPtrs : public nodeWO Ptrs { // internal node type public: nodeWOPtrs
nodeWithPtrs(); // needs default constructor to // guarantee pointers are set };
It is impossible that this situation will cause the parent of the leaf to underflow. If the leaf underflows, and "borrowing" is possible, then the relevant sibling must contain at 51 values (so it won't underflow after losing one). A value is moved from that sibling to the parent, where it replaces the value in the parent that falls "between" the two leaf nodes, and that value is moved into the leaf that underflowed.
This does not change the number of values stored in the parent, so there is no possibility the parent can underflow.
By linking the leaves into a linear list, range searches will be more efficient since it will now be necessary to just search for the smallest value that's larger than or equal to the first value in the range and then perform a linear walk across the leaf level until the first value that's too big is located.
In a B-tree, this would require returning to levels above the leaves in order to continue the search.
a) application that uses a vector to store a collection of records that are searched repeatedly
There would be no significant advantage; the buffer pool can only significantly decrease the cost of retrieving records from disk. There might be a slight gain however; if the searches exhibit some temporal locality, using a cache to store recently-accessed records could make repeated searches for those records cheaper.
b) application that reads sequentially through a data file to build a vector of records
There would be no advantage; no record would be accessed more than once. Since a sequential pass through the file would exhibit spatial locality (in a very simple way), there would be some merit in retrieving a block of records at once from disk. However, this doesn't need, or benefit from the use of a buffer pool.
c) application that uses a file to store a collection of records that are searched repeatedly
In this case, there is the potential that the buffer pool will lead to improved performance, depending on whether the record searches exhibit enough locality.
a) [8 points] Describe a specific physical data structure that would be a good choice if the replacement policy is FIFO.
The records are removed in the order they are inserted, so this is just a queue. Either an array or a singly- linked list would be appropriate. Since the number of slots is fixed, the linked list would use slightly more memory, but that may be offset by the fact that the array would require extra arithmetic for the circular indexing that would be needed.
b) [8 points] Repeat part a if the replacement policy is least frequently used (LFU).
The record to be replaced is the one with the smallest number of hits. If the records were stored in a poor order, this could require a linear search. So, it would be better to store the records in order of their frequency counts. Since that would require swapping records when frequency counts change, it would be best to do this in a way that didn't require too many copy operations. Therefore, a linked list would be a better choice.