Multiple Choice Answers

A node in a binary tree is called a(n) ____ if it has no left and right children.
edge
branch
leaf
path
Every node in a doubly linked list has two pointers: ____ and ____.
previous; next
back; next
current; next
previous; current
In a graph G, if the edges connecting two vertices have weights assigned to them, the graph is called a ____ graph.
source
weighted
spanning
minimal
The edges connecting two vertices can be assigned a non-negative real number, called the ____ of the edge.
key
weight
width
height
The ____ executes when the object goes out of scope.
default constructor
destructor
copy constructor
iterator
Popping an element from an empty stack is called ____.
overflow
underflow
exception
overloading
The addition and deletion of elements of the stack occurs only at the ____ of the stack.
head
bottom
top
middle
In a graph directed G, for each vertex, v, the vertices adjacent to are called ____ successors.
immediate
adjacent
path
parallel
The key of the right child below the root node of a search binary tree is 40. The value in the root node could be ____.
30
40
50
60
What is the purpose of the following code?current = head;while (current != NULL){    //Process current    current = current->link;}
Insertion of a node
Selection of a node
Traversal of a linked list
Creation of a new list
In a linked list, the order of the nodes is determined by the address, called the ____, stored in each node.
head
tail
link
first
A linked list is a collection of components, called ____.
elements
nodes
members
pointers
Which of the following is a basic operation performed on a queue?
push
pop
isEmptyQueue
top
The function ____ of the class linkedListType returns the last element of the list.
tail
lastNode
back
last
The ____ operation returns a pointer to the position before the first element in container ct.
ct.front()
ct.rbegin()
ct.rend()
ct.end()
In a binary search tree, the data in each node is ____ the data in the left child.
larger than
smaller than
equal to
larger or equal to
An iterator to a vector container is declared using the ____ iterator.
new
vector
typedef
typeiter
The ____ nodeType defines the node of a binary tree.
struct
class
template
array
Which of the following correctly initializes a doubly linked list in the default constructor?
head = NULL;back = NULL;
head = 0;back = 0;count = 0;
first = 0;last = 0;
first = NULL;last = NULL;count = 0;
Which of the following is a valid function of the class stackType?
int isEmptyStack() const;
void push();
void pop();
type pop();
Using the binary search algorithm, in an unsuccessful search, how many key comparisons are performed during the last iteration of the loop?
0
1
2
n, where n is the number of items in the list
The link field of the last node of a linked list is ____.
0
1
n-1
n
In a(n) ____ graph, the edges are drawn using arrows.
pointed
vector
directed
undirected
If data needs to be processed in a LIFO manner, use a(n) ____.
stack
linked list
queue
deque
Predicates are special types of function objects that return ____ values.
character
string
Boolean
Integer
Two well-known algorithms, Prim’s algorithm and ____’s algorithm, can be used to find a minimal spanning tree of a graph.
Euler
Dekart
Kruskal
Dijkstra
To describe a queuing system, we use the term ____ for the object receiving the service.
client
server
customer
provider
The initializeList operation on a doubly linked list can be done by using the operation ____.
empty
clear
destroy
delete
The ____ sort algorithm sorts the list by moving each element to its proper place in the sorted portion of the list.
bubble
quick
merge
insertion
The level of the children of the root node is ____.
0
1
2
3
When traversing a binary tree with the pointer current, the pointer current is initialized to ____.
NULL
llink
rlink
root
Each link (pointer) in a binary tree node points to a(n) ____ of that node.
parent
child
value
sibling
Given the unordered list [10, 7, 19, 5, 16], which of the following sequences represents the result of the first iteration of the bubble sort algorithm?
[7, 10, 19, 5, 16]
[10, 7, 5, 16, 19]
[19, 10, 7, 5, 16]
[7, 10, 5, 16, 19]
What is the output of the following code?stackType<int> stack;int x, y;x = 4;y = 2;stack.push(6);stack.push(x);stack.push(x + 1);y = stack.top();stack.pop();stack.push(x + y);x = stack.top();stack.pop();cout << “x = ” << x << endl;
x = 4
x = 5
x = 6
x = 9
What is the access modifier of the variable count in the linkedListType class?
public
private
protected
friend
The sequence of operations in a postorder search is ____.
traverse left; traverse right
traverse left; traverse right; visit
visit; traverse left; traverse right
traverse left; visit; traverse right
Suppose that the pointer head points to the first node in the list, and the link of the last node is NULL. The first node of the linked list contains the address of the ____ node.
head
first
second
tail
The postfix expression 5 6 + 4 * 10 5 / – = evaluates to ____.
10
30
42
44
A queue is a data structure in which the elements are ____.
added to the rear and deleted from the front
added to and deleted from the rear
added to and deleted from the front
added and deleted in the middle
Which of the following operations removes the first element from the deque object deq?
deq.front()
deq.push_front()
deq.pop_front()
deq.push()