CS 235 Test 2 Roper

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

A Huffman tree for an alphabet of 15 distinct characters has ________ leaf nodes. a. 15 b. less than 15 c. 16 d. more than 16

A

If you need to provide a stack, a queue, a deque, an input-restricted deque, and an output restricted queue, ____________________. a. each of the others should "have" a deque as a data member b. each of the others should "be" a deque c. each of the others should extend class stack d. each of the others should extend class queue

A

In a particular binary tree is full and has 100 leaf nodes, how many internal nodes does it have? a. 99 b. 100 c. 101 d. Not determinable.

A

Infix-to-postfix uses a stack of ________, postfix evaluation a stack of ________, and postfix-to-infix a stack of ________. a. operators, operands, operators b. operators, operands, operands. c. strings, strings, strings d. operators, operands, string

A

Pick the correct statement. a. A binary tree is a tree. b. A tree is not a binary tree and a binary tree is not a tree. c. A tree is a binary tree. d. "Tree" and "binary tree" are synonymous.

A

Suppose you want to access the next element of a stack. Which function would you call? a. top() b. pop() c. push() d. next()

A

To check for balanced parentheses, use a stack of: a. parentheses. b. operators and operands. c. operands. d. operators.

A

What happens when a recursive function calls itself? a. A new instance of the function is called. b. The function starts over. c. the old variables get saved and then the function starts over. d. None of the above.

A

What is recursion? a. A problem solving approach that causes functions to call themselves with different arguments. b. a trivial solution to a small problem. c. A way to remove the first element of a list. d. Returning the result of another function.

A

What things are necessary in a recursive function? a. A base case and a recursive call. b. Adding the word "recursive" before the function name. c. Returning either true or false. d. All of the above.

A

When the array representation of ADT queue becomes full, ___________. a. call a reallocate specialized for the array-based queue b. call the reallocate function for vector c. terminate enqueuing d. wrap around to the beginning of the array

A

Which of the following stack configurations are correct in terms of precedence? Let the far left be the bottom of the stack, and the right be the top. a. + % b. * - c. + + d. / *

A

Which of the following would not a good application for a binary tree? a. A family tree. b. A Huffman tree. c. A search tree. d. An expression tree.

A

With the recursive linear search algorithm given in the book, how many items in the list need to be checked if the item is not in the list? a. Every item in the list. b. Half of the items in the list. c. log(n), where n is the number of items in the list. d. None, you don't have to search if the item is not in the list.

A

_______ errors probably exist in a significant portion of commercial software. a. Logic b. Run-time c. Syntax d. Waterfall

A

A Priority Queue a. is a container. b. is a container adapter that uses a specific underlying container, e.g. vector or deque. c. is implemented with a stack. d. sometimes uses a LIFO to implement a waiting line.

B

A Priority Queue is an extension of queue with the following properties: a. A typical priority queue supports an insert(item) function. b. An element with high priority is dequeued before an element with low priority. c. Every item has a unique priority associated with it. d. If two elements have the same priority, both are returned when dequeued.

B

Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap is (A) 40, 30, 20, 10, 15, 16, 17, 8, 4, 35 (B) 40, 35, 20, 10, 30, 16, 17, 8, 4, 15 (C) 40, 30, 20, 10, 35, 16, 17, 8, 4, 15 (D) 40, 35, 20, 10, 15, 16, 17, 8, 4, 30

B

Consider any array representation of an n element binary heap where the elements are stored from index 1 to index n of the array. For the element stored at index i of the array (i <= n), the index of the parent is (A) i - 1 (B) floor(i/2) (C) ceiling(i/2) (D) (i+1)/2

B

For which type of error are try and catch most appropriate? a. Logic errors. b. Run-time errors. c. Syntax error. d. All of the above.

B

If the number 3 is inserted into the following binary tree, what would be the pre-order traversal order? 5 / \ 1 10 / \ / 0 4 7 \ 9 a. 0 1 3 4 5 7 9 10 b. 5 1 0 4 3 10 7 9 c. 5 1 10 0 4 7 3 9 d. None of the above.

B

If the number 5 is deleted from the following binary tree, what would be the level order traversal order? 5 / \ 1 10 / \ / 0 4 7 \ 9 a. 1 0 4 10 7 9 b. 4 1 10 0 7 9 c. 7 1 9 0 4 10 d. 9 1 10 0 4 9

B

Pick the best statement: a. Both the preconditions and postconditions must be met. b. If the preconditions are met, the postconditions must be achieved. c. If the preconditions are not met, the postconditions will not be achieved. d. The preconditions and postconditions are independent of each other.

B

Searching for an item in a linked list is O(_____). Searching in a binary search tree is O(_____). a. n, n b. n, log(n) c. log(n), log(n) d. n^2, n

B

The contiguous implementation of ADT deque is ______________. a. impractical b. more like the contiguous implementation of ADT queue c. more like the contiguous implementation of ADT stack d. unlike the contiguous implementation of either ADT stack or ADT queue

B

True or false: The maze solving algorithm will not function properly if there is more than one possible path through the maze. a. True b. False

B

What is the matching postfix expression to the following infix expression: 7 + (2 * 3) / 9 ? a. 7 2 3 * + 9 / b. 7 2 3 * 9 / + c. 2 3 * 9 / 7 + d. There is none, it is an invalid expression.

B

What makes backtracking different from random trial and error? a. Backtracking is always faster than random trial and error. b. Backtracking is a systematic approach that will not try the same path more than once. c. Random trial and error cannot be made in a program. d. There is no real difference.

B

Which of the following functions is the least efficient when implemented recursively? a. Calculating n factorial (n!). b. Calculating the nth Fibonacci number. c. Finding the greatest common divisor of two numbers. d. Raising x to the power of n.

B

How many base cases are in the maze solving algorithm? a. 1 b. 2 c. 3 d. 4

C

Pick the best statement a. A complete binary tree is a full binary tree. b. A complete binary tree is a full binary tree and a full binary tree is a complete binary tree. c. A full binary tree need not be complete and a complete binary tree need not be full. d. A full binary tree is a complete binary tree.

C

Pick the best statement: a. An ADT is represented by a .cpp file. b. An ADT is represented by a .h file. c. An ADT is represented by a class consisting of abstract functions. d. An ADT is represented by the combination of a .h file and an associated .cpp file.

C

Should a new Huffman tree be built for each file you create? Why or why not? a. No, because one Huffman tree should be enough for any file made in the same language. b. No, because that requires too much code. c. Yes, because different files may contain symbols with different frequencies. d. Yes, because Huffman trees can only be used once, even for the same file.

C

Suppose you want to make a priority queue where smaller numbers have the highest priority. Which of the following would be the best underlying data structure? a. A binary search tree. b. A circular array. c. A min-heap. d. A max-heap.

C

The contiguous implementation of an ADT queue _______________. a. calls for a vector b. calls for a conventional array c. calls for a circular array d. is not practical

C

The reallocate function for the class Queue a. has an unacceptable "Big O". b. typically copies elements to identical index positions. c. typically does not copy elements to identical index positions. d. works only if class Queue extends class Vector.

C

There are two general ways to implement ADT stacks. These are: a. using an array or vector. b. using a single-linked list or a double-linked list c. using a contiguous structure or a linked structure. d. (none of the above; always use the standard library implementation)

C

What is the downside of recursion? a. A negative argument is not allowed in any recursive function. b. If the base case is not reached, an invalid_argument exception is thrown and must be caught. c. The function may result in a run-time error when there is no more memory available. d. There is no downside to recursion.

C

What is the result of the postfix expression 4 7 * 20 - ? a. -136 b. -52 c. 8 d. There is none. It is an invalid expression.

C

What order is used in the C++ tool chain? a. Compiler, preprocessor, assembler, linker. b. Compiler, preprocessor, linker, assembler. c. Preprocessor, compiler, assembler, linker. d. Preprocessor, compiler, linker, assembler.

C

Which of the following most accurately describes the behavior of a stack? a. First in, first out. b. Last in, last out. c. Last in, first out. d. None of the above.

C

A heap a. is a full and complete binary tree. b. is a full binary tree. c. only requires the root value to be greater than or equal to all items in the tree. d. requires every subtree to be a heap.

D

Compared with a linked list, a binary tree _____________. a. is better at representing a sequence of numbers. b. is less effective at representing genealogy c. is virtually the same d. has nodes with two child nodes instead of one next node.

D

For the contiguous representation of ADT deque, when an end of the deque is reached, ______________________. a. allocate a larger array b. shift elements to the left c. shift elements to the right d. wrap around to the other end

D

If the size of a heap is n, the performance a. is O(log n) for insertion. b. is O(1) for deletion. c. is O(n) for deletion. d. is O(n^2) for restructuring.

D

In tail recursion, ______________________. a. progress toward a base case is linear (i.e. each level or recursion entails only a single call) b. progress toward a base case is monotonic c. progress toward a base case is strictly monotonic d. the recursive call is the last executable statement in the function.

D

Pick the best relationship for queues and deques. a. A queue is-a deque. b. a deque is-a queue. c. A deque has-a queue. d. A queue has-a deque.

D

The inorder traversal sequence of a binary tree is A B C. the root is _______. a. A b. B c. C d. Not a unique binary tree

D

Traversal algorithms are fairly simple. What attribute of trees makes that so? a. Trees are linear data structures. b. Trees are normally smaller than other data structures. c. Trees are normally larger than other data structures. d. Trees are recursive data structures.

D

What is the matching infix expression to the following postfix expression: 8 9 + 4 * - ? a. - ((8 + 9) * 4) b. ((8 + 9) * 4) c. - (8 + 9 * 4) d. There is none, it is an invalid expression.

D

When a recursive function returns after three iterations because it hits a base case, where does it return to? a. The beginning of the previous iteration that called it. b. The first iteration. c. The function that called the first iteration. d. The previous iteration, right after it called the next iteration.

D


Set pelajaran terkait

Un1Pt1 Psychology's History & Approaches/ Perspectives

View Set

Macroeconomics 4.1c The Benefits and Costs of Economic Growth

View Set

EURO AND INTERNATIONAL FINANCE QUIZ NO.1

View Set

Sociology Lesson 9 Religion (Textbook Question)

View Set

Federal Tax Considerations for Accident & Health Insurance

View Set