Final Exam Study

¡Supera tus tareas y exámenes ahora con Quizwiz!

1. Consider this method declaration: void quiz(int i) { if (i > 1) { quiz(i / 2); } System.out.print("*"); } How many asterisks are printed by the method call quiz(5)? a. A. 3 b. B. 4 c. C. 7 d. D. 8 e. E. Some other number

7

If the characters 'D', 'C', 'B', 'A' are placed in a queue (in that order), and then removed one at a time, in what order will they be removed? a) ABCD b) ABDC c) DCAB d) DCBA

DCBA

1. What is the importance of the stopping case in recursive methods?

any case without using recursive method

If data is a circular array of CAPACITY elements, and rear is an index into that array, what is the formula for the index after rear? a) (rear % 1) + CAPACITY b) rear % (1 + CAPACITY) c) (rear + 1) % CAPACITY d) rear + (1 % CAPACITY)

(rear + 1) % CAPACITY

If G is an directed graph with 20 vertices, how many boolean values will be needed to represent G using an adjacency matrix? a) 20 b) 40 c) 200 d) 400

400

1. What graph traversal algorithm uses a queue to keep track of vertices which need to be processed? a) Breadth-first search. b) Depth-first search.

Breadth-first search.

One difference between a queue and a stack is: a) Queues require linked lists, but stacks do not. b) Stacks require linked lists, but queues do not. c) Queues use two ends of the structure; stacks use only one. d) Stacks use two ends of the structure, queues use only one.

Queues use two ends of the structure; stacks use only one

Consider the implementation of the Queue using a circular array. What goes wrong if we try to keep all the items at the front of a partially-filled array (so that data[0] is always the front). a) The constructor would require linear time. b) The getFront method would require linear time. c) The insert method would require linear time. d) The isEmpty method would require linear time.

The getFront method would require linear time.

Write two or three clear sentences to describe how a heapsort works.

heapsort works by using larger number in the in top of the tree. All the smaller number goes button of the tree.

1. How many linked lists are used to represent a graph with n nodes and m edges, when using an edge list representation, a) m b) n c) m + n m*n

n

In a selection sort of n element, how may times is the swap function called in the complete execution of the algorithm? a) 1 B) n - 1 C) n long n D) n^2

n-1


Conjuntos de estudio relacionados

Abeka Grade 7 History of the World Quiz 22

View Set

EXAM TWO - STUDY MODULES (Ch. 21, 22, 23)

View Set

Hodder Uni 13-El medio ambiente -- a--(1-74)

View Set

Chapter 35: Communication and Teaching with Children and Families

View Set

Psychology - Assessing Personality

View Set

Spanish 3: -go, -zco, -jo verbs (yo form only)

View Set

Mastering Bio: Cell Cycle, Mitosis and Meiosis

View Set

ch. 54: drugs acting on the upper respiratory tract

View Set