e1Answers - CS367 Exam 1 for Spring 2000 Solution Part I...

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

View Full Document Right Arrow Icon
CS367 Exam 1 for Spring 2000: Solution Part I The question numbers below are for version A. Here is the correspondence: A 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 B 4 3 5 8 7 9 6 1 2 13 14 15 12 11 10 C 9 7 8 2 1 4 3 6 5 15 10 12 14 13 11 For each question in Part I, decide whether true or false is most appropriate for the statement. Mark the appropriate bubble on the answer sheet. 1. (T/ F ) In the worst-case it is possible to add an item to an array-based Sequence in O(1). If the array is full then you must perform a resize and this is O(N). Also, if you add at the beginning of the array then you must shift all the following entries and this is O(N). 2. (T/ F ) In the worst-case it is possible to enqueue into an array-based Queue in O(1). Unlike a Sequence, you don't have the issue of adding at the beginning and having to shift if you use the circular array concept. However, you might need to resize and this is O(N). 3. ( T /F) In the worst-case it is possible to enqueue into a linked list based Queue in O(1). As long as the rear of the Queue is at the head or tail of the linked list you can add in O(1) time. To also make dequeue fast it is best to put the rear at the tail. You don't have to resize a linked list so this is not an issue. 4. ( T /F) For an abstract datatype, the public interface tells all the functionality a user of the abstract datatype needs to know. The user only needs to know what the abstract datatype does. This is what the public interface gives. The details of the implementation should not concern the user. 5. (T/ F ) For an abstract datatype, the public interface includes all fields and methods of the class. The public interface only includes the public methods (and fields if there are any but this is not normal). The private methods and fields are not included in the public interface. 6. ( T /F) For an abstract datatype, the public interface includes the exceptions thrown by the public methods. The exceptions tell the user what can happen and should be included. In Java, the user must know the caught exceptions thrown to deal with them appropriately or the code will not compile. 7. (T/ F ) An implementer of an abstract datatype cannot include any (public or private) methods not listed in the public interface.
Background image of page 1

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

View Full DocumentRight Arrow Icon
The implementer of an ADT can include private methods that are not part of the public interface. This is fine since they are private and the user cannot access them. 8. ( T/F ) An advantage of a doubly linked list Sequence is it uses less memory compared to an array- based Sequence. Either answer was accepted. The original intent was that a doubly linked list uses more memory due to the next and previous references. However, an array can have empty locations. If the fraction of empty locations is more than 2/3 then it uses more space than a doubly linked list. Thus, there is no one right answer. 9. (T/
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.

Page1 / 9

e1Answers - CS367 Exam 1 for Spring 2000 Solution Part I...

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