Help on this questionary. Q. Resolving collisions by sequentially finding the ne
ID: 3914231 • Letter: H
Question
Help on this questionary.
Q. Resolving collisions by sequentially finding the next available location is called
bucketed hashing
linear probing
quadratic probing
double hashing
Q. A hashing function ________.
maps a key to an index in the hash table
resolves conflicts between data with identical hash codes
stores an element in a hash table
is usually implemented recursively
Q. If each key is mapped to a different index in the hash table, this is called hashing.
normal
quadratic
linear
perfect
Q. When is the right subtree of a binary tree processed before the left?
When using an inorder traversal algorithm.
When using a preorder traversal algorithm.
When using a postorder traversal algorithm.
Never. The left always goes before the right in the standard traversal algorithms.
Q. Fill in the code to complete the following method for computing a factorial.
long factorial(int n)
{ if (n == 0) // Base case
return 1;
else
return _____________; // Recursive call }
A) n * factorial(n - 1)
B) factorial(n) * factorial(n - 1)
C) n * (n - 1)
D) n
Q. The ________ traversal algorithm processes the nodes of a binary tree in alphabetical or numeric order.
inorder
preorder
unordered
postorder
Q. Rather than finding a new location for colliding data, a(n) _____ scheme stores the data in linked lists.
bucketing/separate chaining
double hashing
open addressing
linear probing
Q. A binary tree gets its name from the fact that it ________.
involves math and a number system that most people do not understand
is represented in memory using a binary number format
has leaves that resemble little ones and zeros
is made of nodes that have, at most, two children
Q. What is the base case in the following recursive function?
void xMethod(int n)
{ if (n > 0)
{ cout << (n % 10) << endl;
xMethod(n / 10); }
}
A) There is no base case.
B) n != 0
C) n <= 0
D) n > 0
Q. In a preorder tree traversal, each node is processed ____ its children.
before
instead of
relative to the ordinal values of
after
Q. Suppose a list is {2, 9, 5, 4, 8, 1}. After the first pass of bubble sort, the list becomes:
2, 9, 5, 4, 1, 8
2, 1, 5, 4, 8, 9
2, 5, 4, 8, 1, 9
2, 5, 9, 4, 8, 1
2, 9, 5, 4, 8, 1
Q. Which of the following statements is FALSE?
Every recursive call reduces the original problem, bringing it closer to a base case.
Infinite recursion can occur if the problem is not reduced in a way that brings it to a base case.
Every recursive function must return a value.
Every recursive function must have a base case or stopping condition.
Q. Fill in the code to complete the following function for computing a Fibonacci number. Long fib(long index)
{ if (index == 0) // Base case
return 0;
else if (index == 1) // Base case
return 1;
else // Reduction and recursive calls
return __________________;
}
A) fib(index - 2)
B) fib(index + 2) + fib(index + 1)
C) fib(index - 1)
D) fib(index - 1) + fib(index - 2)
Q. A tree node that has zero children is called a ________ node.
root
swollen
leaf
terminal
Q. In hashing, a collision occurs when:
many elements share the same key
we try to insert new data when the hash table is already full
two or more keys map to the same hash value
the requested data is not found
Q. In a postorder tree traversal, each node is processed ____ its children.
instead of
after
before
relative to the ordinal values of
Q17. If you have an array of 4,000 sorted data items, about how many comparisons will it take for a binary search to discover that a certain value is not present?
64
4000
12
It depends on where the value would fall in the array.
Q. In the following recursive function, what is the base case?
int xFunc(int n)
{ if (n == 1) return 1;
else return n + xFunc(n - 1);
}
A) n is less than 1.
B) There is no base case.
C) n is 1.
D) n is greater than 1.
Q. Which of the following statements is true about this recursive function?
long f(int n)
{ return n * f(n - 1);
}
A) Invoking f(1) returns 1.
B) Invoking f(0) returns 0.
C) This function works perfectly for all n > 0.
D) The function runs infinitely and causes a crash.
Q. A binary tree whose left and right subtrees are similar in height is said to be ________.
inefficient
abstract
fictitious
balanced
Explanation / Answer
Linear probing
maps a key to an index in the hash table
perfect
n
in order
open adressing
is made of nodes that have, at most, two children.
C) n <= 0
.
2,9,5,4,8,1
Every recursive function must return a value.
D). fib(index - 1) + fib(index - 2)
leaf
two or more keys map to the same hash value
C) n is 1.
efficient
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.