Exam 3 Combined

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

C

16. If a file contains items in a specified order, how must they be added to put them into a binary search tree in that same order? a. use the method addInOrder b. use the method inOrderAdd c. use the method add d. use the method reOrderAdd

a.

16. The ______ of a tree is the number of nodes on the longest path from the root to a leaf. a. height b. length c. depth d. balance

D

16. The process of enlarging a hash table and computing new hash indices for its contents is called a. re-probing b. de-hashing c. inverse hashing d. re-hashing

c.

17. In a ______ of height h, all nodes that are at a level less than h have two children each. a. general tree b. binary tree c. full binary tree d. complete binary tree

D

17. What efficiency is the tree sort in the average case? a. O(n) b. O(log2 n) c. O(n2) d. O(n * log n)

A

17. You define a hash table so that each location table[i] is itself an array. This array is referred to as a(n) a. bucket b. bracket c. closet d. shelf

b.

18. A ______ of height h is full down to level h - 1, with level h filled in from left to right. a. full binary tree b. complete binary tree c. balanced binary tree d. general tree

d.

19. In ______, the left and right subtrees of any node have heights that differ by at most 1. a. all trees b. all binary tress c. n-ary trees d. balanced binary trees

a.

2. A heap whose root contains the item with the smallest search key is called a ______. a. minheap b. maxheap c. complete heap d. binary heap

B

2. Consider an array-based representation of a tree and a variable called root as the index to the tree's root node. What value does the text suggest to assign to root if the tree is empty? a. 0 b. -1 c. 1 d. nullptr

d.

2. The ADT stack manages an association between data items and the ______ of the data items. a. names b. values c. sizes d. positions

B

2. What does the ADT dictionary use to identify its entries? a. it's position in the list b. a search key c. its priority d. what group it belongs to

d.

20. Which of the following is NOT a property of a complete binary tree of height h? a. all nodes at level h - 2 and above have two children each b. when a node at level h - 1 has children, all nodes to its left at the same level have two children each c. when a node at level h - 1 has one child, it is a left child d. all leaves are at level h

a.

21. The traversal of a binary tree is ______. a. O(n) b. O(1) c. O(n2) d. O(log2 n)

a.

22. Any data element within a record of a binary search tree is called a ______. a. field b. tree c. collection d. key

b.

23. The maximum number of comparisons for a retrieval operation in a binary search tree is the ______. a. length of the tree b. height of the tree c. number of nodes in the tree d. number of leaves in the tree

a.

24. The maximum height of a binary tree of n nodes is ______. a. n b. n / 2 c. (n / 2) - 2 d. log2(n + 1)

d.

25. The minimum height of a binary tree of n nodes is ______. a. n b. n / 2 c. (n / 2) - 2 d. ⎡log2(n + 1)⎤

a.

26. Locating a particular item in a binary search tree of n nodes requires at most ______ comparisons. a. n b. n / 2 c. (n / 2) - 2 d. ⎡log2(n + 1)⎤

d.

27. Locating a particular item in a balanced binary search tree of n nodes requires at most ______ comparisons. a. n b. n / 2 c. (n / 2) - 2 d. ⎡log2(n + 1)⎤

c.

28. A full binary tree whose height is 4 has ______ nodes. a. 7 b. 8 c. 15 d. 31

D

29. The post order traversal of the following tree is a. 1, 2, 3, 4, 5, 6, 7, 8, 9 b. 6, 2, 1, 4, 3, 5, 8, 7, 9 c. 6, 2, 8, 1, 4, 7, 9, 3, 5 d. 1, 3, 5, 4, 2, 7, 9, 8, 6

d.

3. A heap is a ______. a. general tree b. table c. full binary tree d. complete binary tree

C

3. In an array-based representation of a tree, what keeps track of available nodes? a. the variable emptyCount b. the variable nextAvailable c. the free list d. the node list

b.

3. The operations of the ADT sorted list are based upon the ______ of data items. a. names b. values c. sizes d. positions

C

3. Which of the following is not an ADT dictionary operation? a. add a new entry b. retrieve an entry c. sort the entries d. traverse the entries in sorted search-key order

D

30. Each node in a binary tree has ______. a. exactly one child b. at most one child c. exactly two children d. at most two children

B

31. The maximum number of comparisons for a retrieval operation in a binary search tree is the ______. a. length of the tree b. height of the tree c. number of nodes in the tree d. number of leaves in the tree

b.

4. A semiheap is a ______. a. table b. complete binary tree c. general tree d. full binary tree

c.

4. The ______ is a position-oriented ADT that is not linear. a. sorted list b. queue c. binary tree d. list

D

4. What do you do if you remove a node from a tree in an array-based implementation? a. assign it to nullPtr b. nothing, leave it as is, just don't link anything to it c. remove it from the array d. add it to the free list

D

4. Which of the following is the better choice when attempting to add a new entry to a dictionary where the search key already exists? a. replace the existing entry with a new entry b. crash the program c. throw an exception d. deny the attempt

d.

5. In an array-based implementation of a heap, the number of array items that must be swapped to transform a semiheap of n nodes into a heap is ______. a. n b. n + 1 c. log2 n d. log2 (n + 1)

A

5. In the class BinaryNode, which of the following methods are specified as type bool? a. isLeaf b. setItem c. setLeftChildPtr d. getLeftChildPtr

A

5. In the header file for the class ArrayDictionary, the text declares which of the following methods as private? a. destroyDictionary() b. isEmpty() c. getNumberOfEntries() d. clear()

a.

5. Which one of the following ADTs is position-oriented? a. binary tree b. sorted list c. table d. priority queue

d.

6. In an array-based implementation of a heap, the remove operation is ______. a. O(1) b. O(n) c. O(n 2) d. O(log n)

B

6. In the class ArrayDictionary declared by the text, which of the following methods bears the responsibility for keeping the array items sorted? a. remove b. add c. getValue d. traverse

D

6. In the class BinaryNode, what value is stored in rootPtr if the tree is empty? a. 0 b. -1 c. 1 d. nullptr

b.

6. The node of a tree that has no parent is called a(n) ______. a. edge b. root c. leaf d. vertex

C

7. According to the text, for the ADT dictionary, in which of the following situations would a sorted array-based implementation be appropriate for frequent retrievals? a. when the maximum size is unknown b. when the maximum size is known c. when you have duplicate search keys d. when search keys are all similar.

b.

7. In an array-based implementation of a heap, the parent of the node in items[i] is always stored in ______. a. items[i/2] b. items[(i-1)/2] c. items[i-2] d. items[(i-2)/2]

B

7. In the class BinaryNode, if the tree is not empty, what points to the root's left child? a. getLeftHildPtr() b. rootPtr->getLeftChildPtr() c. getLeftChildPtr()-> rootPtr d. leftChildPtr

b.

7. The lines between the nodes of a tree are called ______. a. branches b. edges c. arches d. subtrees

D

8. According to the text, for the ADT dictionary, what implementation should be used when you do not know the maximum size of the dictionary? a. link-based b. array-based c. max-heap d. binary search tree

d.

8. In an array-based implementation of a heap, the add operation is ______. a. O(1) b. O(n) c. O(n 2) d. O(log n)

c.

8. The node that is directly above node n in a tree is called the ______ of node n. a. root b. leaf c. parent d. child

C

8. What overladed operator did the class BinaryNodeTree have specified in the text? a. less than b. not c. assignment d. plus (concatenation)

d.

9. A node directly below node n in a tree is called a ______ of node n. a. root b. leaf c. parent d. child

A

9. According to the text, for the ADT dictionary, a sorted array-based implementation will shift data during what two operations? a. additions and removals b. additions and traversals c. removals and traversals d. searches and gets

c.

9. The heapsort is ______ in the worst case. a. O(n) b. O(log n) c. O(n * log n) d. O(n2)

D

9. To copy a tree, traverse it in __________ and add each data item visited to a new node. a. inorder b. postorder c. reorder d. preorder

b.

1. A heap whose root contains the item with the largest search key is called a ______. a. minheap b. maxheap c. complete heap d. binary heap

b.

1. The ADT ______ is value-oriented. a. list b. sorted list c. stack d. queue e. binary tree

A

1. The ADT dictionary is appropriate for problems that must manage data by a. value b. order c. priority d. importance

A

1. What is the first step in implementing a tree? a. choose a data structure to represent its nodes b. determine the type of item to be stored in the tree c. determine the height of the tree d. determine how many items will be in the tree

b.

10. In a tree, the children of the same parent are called ______. a. leafs b. siblings c. roots d. contemporaries

d.

10. The heapsort is ______ in the average case. a. O(1) b. O(n) c. O(log n) d. O(n * log n)

A

10. What is the classification of the method getHeightHelper? a. protected b. private c. public d. restricted

B

10. Which of the following dictionary operations has efficiency O(n) no matter what implementation if the ADT dictionary is chosen? a. retrieval b. traversal c. removal d. addition

b.

11. Each node in a tree has ______. a. exactly one parent b. at most one parent c. exactly one leaf d. at most two leaves

B

11. Given the following code from BinaryNodeTree template<class ItemType> bool BinaryNodeTree<ItemType>::________(const ItemType& newData) { auto newNodePtr = std::make_shared<BinaryNode<ItemType>>(newData); rootPtr = balancedAdd(rootPtr, newNodePtr); return true; } // end add What is the name of this method? a. getHeight b. add c. remove d. getEntry

C

11. What is the implementation of the ADT dictionary which has efficiency O(log n) for addition? a. unsorted link-based b. sorted array-based c. binary search tree d. sorted link-based

a.

11. Which of the following is true about the heapsort? a. the heapsort does not require a second array b. the heapsort is more efficient than the mergesort in the worst case c. the heapsort is more efficient than the mergesort in the average case d. the heapsort is better than the quicksort in the average case

b.

12. A node on the path from the root to node n is a(n) ______ of node n. a. ancestor b. descendant c. subtree d. leaf

C

12. In the class BinaryNodeTree, the protected method inorder has a parameter visit. What is the specification for this parameter? a. virtual b. value c. reference d. dummy

b

12. Since a heap is a complete binary tree, what would be an efficient basis for its implementation? a. pointer based b. array based c. a bag d. a set-based

D

12. What is the implementation of the ADT dictionary which has efficiency O(1) for addition? a. sorted link-based b. sorted array-based c. binary search tree d. unsorted link-based

b.

13. A descendant of node n is a node on a path from node n to ______. a. the root b. a leaf c. a sibling of node n d. a child of node n

D

13. To save a binary search tree in a file and then restore it to its original shape, what type of traversal should be used? a. postorder b. inorder c. reorder d. preorder

A

13. What kind of function tells you where a dictionary entry is currently or will be placed if it is new? a. hash function b. logarithmic function c. interrogatory function d. big O function

a.

14. A subtree of node n is a subtree rooted at ______. a. node n b. the parent of node n c. a child of node n d. a sibling of node n

A

14. To remove a leaf in a binary search tree, what must be done? a. set the pointer in the leaf's parent to nullptr b. set the pointer in the leaf to nullptr c. set the pointer in the root to nullptr d. delete the data from the leaf

B

14. What is it called when a hash function maps two or more search keys into the same integer a. an accident b. a collision c. a perfect hash function d. an exception

d.

15. Each node in a binary tree has ______. a. exactly one child b. at most one child c. exactly two children d. at most two children

B

15. If node N is being removed from a binary search tree and has a left child, what must be done if P is the parent of N? a. let the left child of N adopt P b. let P adopt the left child of N c. store the data of the left child of N in N d. store the data of N in P

C

15. When you begin at the hash location and search the dictionary sequentially, this is called what? a. closed addressing b. Horner's rule c. linear probing d. inverse probing


Kaugnay na mga set ng pag-aaral

Ch. 10 Body Weight and Composition for Health and Sports

View Set

Psych Chapter 7: Principles of Learning

View Set

Antitrust Law in the Environment of Business

View Set

MGMT 363 Final (Ch. 13, 14, 16, & HR)

View Set

Sherpath EAQ CH 11: High Risk Perinatal Care: Preexisting Conditions

View Set

Ch5 Ethics in international business

View Set

T10 Superannuation & Retirement Planning

View Set

nclex questions med surg/patho exam 3

View Set