CSS CSPC 250 Midterm 2 Ch13, 15, 16, 17

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

In a maxheap, the root contains a search key greater than or equal to the search key in each of its children a. True b. False

A

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

A

In the class BinaryNodeTree, the methods that use the parameter visit can modify the tree's data, but not its structure. a. True b. False

A

In the class BinaryNodeTree, the public traversal methods each call a protected method that performs the actual recursion. a. True b. False

A

It is possible to use a queue in conjunction with a stack to reverse the order of occurrences of a sequence of items. a. True b. False

A

Lining up to buy a movie ticket or being put on hold by a computerized phone system are both examples of what type of ADT? a. queue b. stack c. list d. sorted list

A

Making methods protected enables a derived class to use them directly a. True b. False

A

The ADT binary tree is position-oriented. a. True b. False

A

The add method of BinaryNodeTree does not indicate where that new data should be in the tree. a. True b. False

A

The height of a binary search tree is sensitive to the order in which items are inserted into the tree. a. True b. False

A

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

B

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

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

B

A reference parameter in a protected method does not allow the client code to modify the parameter. a. True b. False

B

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

B

A tree whose height is h has its root at level h. a. True b. False

B

According to the text, an array-based implementation of a binary tree is much less attractive when the tree is complete. a. True, be gone THOT b. False, niBBa cute

B

An even driven simulation simulates the ticking of a clock. a. True b. False

B

An inorder traversal visits a node before it traverses either of the node's subtrees. a. True b. False

B

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

B

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

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

B

Given the following queue operations on an empty existing queue called nameQueue. nameQueue.enqueue(Sid) nameQueue.enqueue(Sal) nameQueue.enqueue(Sue) nameQueue.enqueue(Sam) nameQueue.dequeue() display (nameQueue.peekFront()) What name is displayed? a. Sid b. Sal c. Sue d. Sam

B

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

B

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

B

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

The merge sort is more efficient than the heap sort in the worst case. a. True b. False

B

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

B

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

B

An event list contains all future arrival events and what else? a. departure events b. event loops c. clock time d. externally generated events

A

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

A

For class BinaryNodeTree, the copy constructor and the destructor each call a recursive method. a. True b. False

A

For class BinaryNodeTree, the copy constructor and the destructor implicitly use traversal. a. True b. False

A

Given two initially empty queues, queue1 and queue2 and the following commands. queue1.enqueue(1) queue1.enqueue(2) queue2.enqueue(3) queue2.enqueue(4) queue1.dequeue() queueFront = queue2.peekFront() queue1.enqueue(queueFront) queue1.enqueue(5) queue2.dequeue() queue2.enqueue(6) What are now the contents of What is now the contents of queue1 (with front of the queue listed leftmost)? a. 2, 3, 5 b. 5, 3, 2 c. 4, 6 d. 6, 4

A

If you create a queue of assignments and access the queue by due dates of the assignments this is called a priority queue. a. True b. False

A

If you use an array-based implementation of a complete binary tree, you must be sure that the tree remains complete as a result of additions or removals a. True b. False

A

In Order a. Left, Root, Right b. Left, Right, Root c. Root, Left, Right

A

In a heap, the search keys of the children of a particular node have no relationship to each other. a. True b. False

A

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)]

A

Queues are important in simulating and analyzing the behavior of complex systems. a. True b. False

A

The ADT bag does not order its entries. a. True b. False

A

The ADT binary search tree is value-oriented. a. True b. False

A

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

A

The in order traversal is only applicable to binary trees. a. True b. False

A

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

A

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

A

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

A

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

A

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

A

When a node is removed from a tree and returned to the free list, it could be anywhere in the array. a. True b. False

A

Which ADT would be best use to model the customers at a bakery who take numbers to mark their turn? a. queue b. stack c. list d. bag

A

Which of the following are not position-oriented ADTs? a. bag b. stack c. list d. queue

A

Which of the following characterizes a queue? a. FIFO b. LIFO c. FILO d. LILO

A

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

A

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

A

You are put on hold when you call customer service. The automated system tells you an approximation of how long a wait you will have. This is most likely being modeled by a queue. a. True b. False

A

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

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

Post Order a. Left, Root, Right b. Left, Right, Root c. Root, Left, Right

B

Queue is a First-in-Last-out data structure. That is, the last element inserted into a queue is removed first. a. True b. False

B

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

B

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

B

The ADT queue is value-oriented. a. True b. False

B

The add method of BinaryNodeTree concatenates two trees. a. True b. False

B

The class BinaryNodeTree had only the default constructor. a. True b. False

B

The goal of simulation is to generate reports of transactions. a. True b. False

B

The isEmpty function for a stack does a much different task than the same function for a queue. a. True b. False

B

The postorder traversal of a binary search tree will visit the tree's data items in sorted order. a. True b. False

B

The root of a tree has one parent. a. True b. False

B

The traversals of a binary search tree differ from the traversals of a binary tree. a. True b. False

B

Which of the following characterizes a stack? a. FIFO b. LIFO c. FILO d. LILO

B

Which of the following is not a similarity between a stack and a queue as described by the text? a. both have an isEmpty method b. both can retrieve an item from any position c. both can insert an entry at one end of the structure d. both can retrieve an entry from one end of the structure

B

Which of the following tasks would be a good application of the ADT Queue? a. generating random numbers for a game b. reading a string of characters c. keeping a grocery list d. parsing a mathematical expression such as (9 + 5) * 7^ 2

B

Which of the following would be an example of a value-oriented ADT? a. bag b. priority queue c. list d. stack

B

You are watching old reruns of M.A.S.H. You notice that when a group of casualties arrive, the doctors and nurses are, in effect using an ADT stack to determine who goes to the operating room first. a. True b. False

B

You are writing a simple word processor. What ADT would be best to use which would allow the typist to correct typing errors by using the Backspace key. a. queue b. stack c. list d. sorted list

B

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

C

A large corporation is facing financial troubles and finds that they must do a reduction in force (RIF). The people who were most recently hired must be let go. This is an example of which ADT? a. bag b. list c. stack d. queue

C

A priority queue orders its items by ______. a. position b. value c. priority value d. size

C

According to the text, the first step in simulating a system is to do what? a. write a computer program b. time events with a stopwatch c. construct a mathematical model d. hire a lawyer

C

For a stack, the push method places a new item onto the stack. What method for the queue would do a similar task? a. dequeue b. isEmpty c. enqueue d. peek

C

Given the following queue operations on an empty existing queue called nameQueue. nameQueue.enqueue(Bob) nameQueue.enqueue(Bill) nameQueue.enqueue(Bud) nameQueue.dequeue() nameQueue.enqueue(Boo) What is now the contents of the queue (with front of the queue listed leftmost)? a. Bob, Bill, Bud b. Bob, Bud, Boo c. Bill, Bud, Boo d. Boo, Bud, Bill

C

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

C

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

C

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

C

In an event driven simulation, how is simulated time advanced? a. by a single time unit b. by a stop watch c. advanced to the time of the next event d. by a calendar

C

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

C

Pre Order a. Left, Root, Right b. Left, Right, Root c. Root, Left, Right

C

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

C

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

C

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

What ADT would be used along with a queue to determine if a string is a palindrome? a. list b. sorted list c. stack d. priority queue

C

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

C

Which of the following ADT Queue operators does not have return type specified as bool? a. isEmpty b. dequeue c. peekFront d. enqueue

C

Which of the following is not an ADT Queue operation as presented by the author? a. test if queue is empty b. add new entry to back of queue c. add new entry to front of queue d. get entry that was added earliest to the queue

C

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

D

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

D

An algorithm performing simulation of an oft repeated cycle, measuring the times and generating statistics is called what? a. customer loop b. timing loop c. statistical loop d. event loop

D

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

D

For a queue, the dequeue removes the first item. What method for the stack is used to remove the appropriate item? a. peek b. poke c. enqueue d. pop

D

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

D

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)

D

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)

D

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)

D

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

D

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)]

D

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

D

The first item to be removed from a priority queue is the item ______. a. at the front of the priority queue b. at the end the priority queue c. with the highest value d. with the highest priority value

D

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

D

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

D

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

D

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

D

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

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)

D

Which data structure represents a waiting line and limits insertions to be made at the back of the data structure and limits removals to be made from the front? a. Stack. b. tree. c. Linked list d. Queue.

D

Which of the following ADT Queue operators has a parameter? a. isEmpty b. dequeue c. peekFront d. enqueue

D

According to the text, it is natural to make each node an object. a. True b. False

A

All trees are hierarchical in nature. a. True b. False

A

A balanced binary search tree has the minimum height possible for the tree. a. True b. False

A

A binary search tree is a binary tree. a. True b. False

A

A complete binary tree with n nodes has a height of log2(n + 1). a. True b. False

A

A full tree with exactly n = 2h − 1 nodes for some height h has the exact middle of the data items in its root. a. True b. False

A

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

A

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

In an array-based implementation of a binary tree, the data member free is the index of the index of the first node in the free list. Therefore the next available node will always be at index free + 1. a. True b. False

B

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

B

A balanced binary search tree decreases the efficiency of the ADT operations a. True b. False

B

A binary tree cannot be empty a. True b. False

B

Given two initially empty queues, queue1 and queue2 and the following commands. queue1.enqueue(1) queue1.enqueue(2) queue2.enqueue(3) queue1.enqueue(4) queue1.dequeue() queueFront = queue1.peekFront() queue1.enqueue(queueFront) queue2.enqueue(5) queue1.dequeue() queue2.enqueue(7) What is the sum of the contents of queue2? a. 4 b. 15 c. 19 d. none of these

B

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

B

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

D

You are making a "to do" list for this week. You brainstorm all the things which need your attention, then you arrange them from most important to least. You have just used what kind of ADT? a. list b. sorted list c. stack d. priority queue

D

You wish to model who gets to land first as airplanes arrive at a busy airport. What kind of simulation would this be? a. time-driven simulation b. customer-driven simulation c. a sorted list d. event-driven simulation

D


संबंधित स्टडी सेट्स

CSCI 315: Laravel, Flask, Docker

View Set

Mga Batayang Konseptong Pangwika

View Set