1052 exam 3
What is a good value for the load factor in a hash table? 42 0.5 0.75 1.0 0.001
0.75
A node at index 9 has child nodes at what index or indexes? 18 and 19 19 and 20 10 and 18 10 and 11 4
19 and 20
A heap node at index 11 has a parent node at what index? 5 6 24 4 23
5
Tree in which each node has at most two children.
binary tree
Which of these terms is used to indicate where a chained hash table stores entries that have identical indexes? entry bucket hashing key chain
bucket
different keys hash to identical indexes
collision
Tree in which internal nodes are questions.
decision tree
Connection between two tree nodes.
edge
Tree in which internal nodes are operators.
expression tree
The HashSet class uses an underlying binary search tree to manage the elements in a map. True False
false
The intersection method of the Set interface in the Java API returns a set containing elements that are common in two other sets. True False
false
output of hashing
hash code
uses hashing to generate an index
hash function
uses linked lists
chaining
Tree in which a node can have any number of children.
general tree
The values in an associative array must be unique, but the keys don't have to be unique. T/F?
False
A hash function is used to determine where to store each key/value entry. True False
True
In the BinarySearchTree class, which operation does NOT rely on recursion? add remove get contains size isEmpty
isEmpty
Node with no children.
leaf
finds next available index
linear probing
Nodes between the root and a node along edges.
path
always unique
perfect hashing
The union of two sets is accomplished by adding the elements in one set to the other. True False
True
Unlike other collections, a for-each loop is not used to traverse the map collection itself. True False
True
When a hash table performs rehashing, its size is increased and all entries are stored in the new, larger hash table. True False
True
he field of cybersecurity sometimes uses hashing as a form of data encryption. True False
True
Given an initially empty stack named myStack, what would the stack look like after the following operations? Assume the answers show the top of the stack on the left.myStack.push(L) myStack.push(X) myStack.push(R) myStack.push(N) myStack.push(F) L X R N F L R F N R X F N R X L
F N R X L
A HashMap keeps the map keys in the order in which they were added. True False
False
All values stored in a map must be unique. True False
False
Hashing makes it easy for hackers to crack any password they want by brute force. T/F?
False
The BinarySearchTree implementation of a BST does not allow duplicate elements. True False
False
The Java API defines a queue using the LinkedQueue class. T/F?
False
The difference between a min heap and a max heap is that a min heap is partially ordered while a max heap is not. T/F?
False
The heapifyUp method repeatedly swaps the element at the root until the heap property is satisfied. T/F?
False
The removeMin method in a min heap returns the element at the root of the heap, but it does not modify the heap itself. T/F?
False
The subtraction operator make an ideal compression function. T/F?
False
A queue operates in which manner? First In, First Out Status ordered Size ordered Last In, First Out
First In, First Out
What is a stacks colelction?
LIFO
Given an initially empty queue named myQueue, what elements will be in the queue, from front to back, after the following operations are performed?myQueue.add(L) myQueue.add(M) myQueue.remove() myQueue.add(N) myQueue.add(O) myQueue.remove() myQueue.add(P) N, O, P M, N, O, P P, O, N, M P, O, N
N O P
The order in which elements are added to a binary search tree determines the shape of the tree. True False
True
The remove method of the Queue interface in the Java API throws an exception if the queue is empty. True False
True
Which statement is NOT true about a binary search tree? All elements in a right subtree are greater than the element in the parent node. Every node is the root of a binary search tree. The element in the root node is greater than any of its descendents. Each node has at most two children.
The element in the root node is greater than any of its descendents.
Which of the following is NOT one of the situations addressed when removing an element from a binary search tree? The element is in a node with one child. The element is in a node with two children. The element is in a leaf node. The element is null.
The element is null.
Given an initially empty stack named myStack, what would the stack look like after the following operations? Assume the answers show the top of the stack on the left.myStack.push(G) myStack.pop() myStack.push(B) myStack.pop() myStack.push(L) myStack.pop() myStack.push(Z) myStack.push(S) myStack.pop() myStack.pop() G B B G S Z Z S The stack is empty. An exception would be thrown.
The stack is empty.
A hash table is a data structure that maps keys to associated values. True False
True
A map collection is a good choice to use when implementing a dictionary. True False
True
A stack would be an appropriate choice for implementing an undo feature. True False
True
A stack's peek operation does not remove an element from the stack. True False
True
Chaining is used in a hash table as a form of collision resolution. True False
True
Collision resolution is needed when the hashing of two different keys produces the same index. True False
True
Even though a heap is a type of tree data structure, it can be represented using an array. True False
True
Hashing is a mathematical approach that converts an arbitrary key into a fixed length hash code. True False
True
It's appropriate to use a binary search tree to implement a collection such as a set or map. True False
True
Most BST operations implemented in the BinarySearchTree class use a public method that calls a private, recursive method. True False
True
The LinkedList class in the Java API implements the Queue interface. True False
True
The classes that implement a set in the Java API are designed to be efficient when finding elements in the set. True False
True
The data structure used internally in a map implementation is designed for efficient value retrieval. True False
True
The java.util.Stack class operates on a generic type that is specified when the stack is instantiated. True False
True
iven an initially empty stack named myStack, what would the stack look like after the following operations? Assume the answers show the top of the stack on the left.myStack.push(T) myStack.push(M) myStack.push(K) myStack.pop() myStack.push(Y) myStack.push(W) myStack.push(H) myStack.pop() myStack.pop() T M Y Y M T H W Y Y W H The stack is empty. An exception would be thrown.
Y M T
Which method is used to add a key/value entry to a hash table? put remove code rehash hashFunction
put
Node at the top of the tree.
root
Node with the same parent.
sibling
Visiting each node in a tree.
traversal