final_sample_questions_2007_solution

final_sample_questions_2007_solution - Computer Science...

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

View Full Document Right Arrow Icon
Computer Science 1037a Sample Questions for the Final Examination Part I: True/False and multiple choice answers. Circle your answers on the question sheet, and fill them in on the Scantron form 1. [1 mark] A list is a last-in first-out data structure. a) True b) False 2. [1 mark] A bag is an example of a linear data structure. a) True b) False 3. [1 mark] A queue is an example of a first-in first-out data structure. a) True b) False 4. [1 mark] If a queue uses a linked list container to hold its items, the enqueue , dequeue and peek operations will all have O(1) time complexities. a) True b) False 5. [1 mark] A node object for BST (binary search tree) requires the same amount of memory as a node for a doubly linked list . a) True b) False 6. [1 mark] Why is class Node declared within the scope of class LinkedList ? a) To avoid confusion with class Node used in BST and/or DLinkedList b) To stop users from direct access to Nodes 7. [1 mark] Suppose we have a LinkedList implementation that uses head and tail pointers. By making it a doubly-linked list rather than a singly-linked list, the improvement in time complexity for the removeTail operation is: a) From O(n) to O(1) b) From O(1) to O(n) c) From O(n) to O(log 2 n) d) From O(n-1) to O(1) e) None of the above
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 8. [1 mark] It is OK to return a pointer to a local variable in C++. a) True b) False 9. [1 mark] C++ code sequence below causes a memory leak . Queue<int> * m = new Queue<int>; Queue<int> *k = m; a) True b) False 10. [1 mark] At any moment of time, the call frame at the top of the call stack corresponds to a function that is being executed. a) True b) False 11. [1 mark] The template class for List is a) a blueprint for a family of list classes that differ only in the kinds of data items they can store. b) code that needs to be compiled only once when working with lists storing different types of data items. c) all of the above 12. [1 marks] The C++ declaration Queue<Bag<int>*> *s = new Queue<Bag<int>*>; a) Creates a statically-allocated queue object that can store pointers to Bag objects that contain integers b) Creates a statically-allocated queue object that can store Bag objects that contains pointers to int objects c) Creates a dynamically-allocated queue object that can store pointers to a Bag objects that contains integers d) Creates a dynamically-allocated queue object that can store Bag objects that contains pointers to int objects 13. [1 mark] Iterators for LinkedList are objects that can be used for a) forward traversals b) backward traversals c) all of the above
Background image of page 2
3 The binary tree drawn below is for use with the next five questions. Data values are not shown in the nodes, but the nodes are labeled with letters. 14.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/26/2009 for the course CS cs1037 taught by Professor Yuri during the Fall '07 term at UWO.

Page1 / 15

final_sample_questions_2007_solution - Computer Science...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online