Deck 7: Sets and Maps

Full screen (f)
exit full mode
Question
Using a hash table enables us to retrieve an item in O(n2) time.
Use Space or
up arrow
down arrow
to flip the card.
Question
Collections implementing the Set interface must contain unique elements.
Question
Sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element.
Question
With respect to hash tables, if there are no collisions, the performance for search and retrieval is O(n), regardless of table size.
Question
Although you cannot reference a specific element of a Set, you can iterate through all its elements using an Iterator object.
Question
The basis of ____________________ is to transform the item's key value to an integer value which will then be transformed into a table index.
Question
In ____________________ addressing, each hash table element (type Object) references a single key-value pair.
Question
The Java API implements the Set using a(n) ____________________.
Question
The problem with ____________________ probing is that it tends to form clusters of keys in the table, causing longer search chains.
Question
Mathematically, a(n) ___________________ is a set of ordered pairs whose elements are known as the key and the value.
Question
An alternative to open addressing is a technique called _____________________.
Question
An addressing technique in which each table element references a linked list that contains all the items that hash to the the same table index is referred to as _________________________.
Question
In ____________________ addressing, search chains can overlap, so a search chain may include items in the table that have different starting values.
Question
An advantage of ____________________ is that you can store more elements in the table than the number of table slots (indexes).
Question
One requirement on the key-value pair for a Map object is to implement the interface ____________________, which is an inner interface of interface Map.
Question
Method ____ creates a set view of the entries in a Map.

A) setIterator
B) getValue
C) getKey
D) entrySet
Question
____ occur(s) because you can only store one key-value pair in a given array element.

A) Quadratic probing
B) Hashing
C) Collisions
D) Backtracking
Question
If we compare hash table performance with binary search of a sorted array, the number of comparisons required by binary search is ____.

A) O(1)
B) O(n)
C) O(log2n)
D) O(log n)
Question
The intersection of sets A, B is a set ____.

A) whose elements belong to A but not to B
B) whose elements belong to both A and B
C) whose elements belong either to A or B or to both A and B
D) set where every element of A is also an element of B
Question
Which of the following is a commonly used method of the Set interface?

A) boolean ContainsAll(Collection<E> coll)
B) boolean retain<E>(E obj)
C) boolean remove(Collection coll)
D) boolean Empty()
Question
With respect to the Map interface, the ____ method returns the current value associated with a given key.

A) isEmpty
B) insert
C) put
D) get
Question
With respect to the Map interface, the ____ method either inserts a new mapping or changes the value associated with an existing mapping.

A) get
B) isEmpty
C) put
D) insert
Question
Which of the following is an example of a map?

A) { (J, Jane), (B, Bill), (S, Sam), (B1, Bob), (B, Bill) }
B) { (J, Jane), (B, Bill), (S, Sam), (B1, Bob), (B2, Bill) }
C) { (J, Jane), (B, Bill), (S, Sam), (B1, Bob), (J, Jane) }
D) { (S, Sam), (B, Bill), (S, Sam), (B1, Bob), (B2, Bill) }
Question
The union of two sets A, B is a(n) ____.

A) set whose elements belong to both A and B
B) set whose elements belong to A but not to B
C) set where every element of A is also an element of B
D) set whose elements belong either to A or B or to both A and B
Question
The following is an algorithm for ____.
Compute the index by taking the item's hashCode() % table.length.
If table[index] is null
The item is not in the table.
Else if table[index] is equal to the item
The item is in the table.
Else
Continue to search the table by incrementing the index until either the item is found or a null entry is found.

A) rehashing
B) accessing an item in a hash table
C) deleting an item in a hash table
D) inserting an item in a hash table
Question
A NavigableSet (NavigableMap) allows the programmer to create _____________ of a Set (Map).
Question
A NavigableSet (NavigableMap) can be traversed in reverse order.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/27
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 7: Sets and Maps
1
Using a hash table enables us to retrieve an item in O(n2) time.
False
2
Collections implementing the Set interface must contain unique elements.
True
3
Sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element.
True
4
With respect to hash tables, if there are no collisions, the performance for search and retrieval is O(n), regardless of table size.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
5
Although you cannot reference a specific element of a Set, you can iterate through all its elements using an Iterator object.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
6
The basis of ____________________ is to transform the item's key value to an integer value which will then be transformed into a table index.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
7
In ____________________ addressing, each hash table element (type Object) references a single key-value pair.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
8
The Java API implements the Set using a(n) ____________________.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
9
The problem with ____________________ probing is that it tends to form clusters of keys in the table, causing longer search chains.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
10
Mathematically, a(n) ___________________ is a set of ordered pairs whose elements are known as the key and the value.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
11
An alternative to open addressing is a technique called _____________________.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
12
An addressing technique in which each table element references a linked list that contains all the items that hash to the the same table index is referred to as _________________________.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
13
In ____________________ addressing, search chains can overlap, so a search chain may include items in the table that have different starting values.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
14
An advantage of ____________________ is that you can store more elements in the table than the number of table slots (indexes).
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
15
One requirement on the key-value pair for a Map object is to implement the interface ____________________, which is an inner interface of interface Map.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
16
Method ____ creates a set view of the entries in a Map.

A) setIterator
B) getValue
C) getKey
D) entrySet
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
17
____ occur(s) because you can only store one key-value pair in a given array element.

A) Quadratic probing
B) Hashing
C) Collisions
D) Backtracking
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
18
If we compare hash table performance with binary search of a sorted array, the number of comparisons required by binary search is ____.

A) O(1)
B) O(n)
C) O(log2n)
D) O(log n)
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
19
The intersection of sets A, B is a set ____.

A) whose elements belong to A but not to B
B) whose elements belong to both A and B
C) whose elements belong either to A or B or to both A and B
D) set where every element of A is also an element of B
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following is a commonly used method of the Set interface?

A) boolean ContainsAll(Collection<E> coll)
B) boolean retain<E>(E obj)
C) boolean remove(Collection coll)
D) boolean Empty()
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
21
With respect to the Map interface, the ____ method returns the current value associated with a given key.

A) isEmpty
B) insert
C) put
D) get
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
22
With respect to the Map interface, the ____ method either inserts a new mapping or changes the value associated with an existing mapping.

A) get
B) isEmpty
C) put
D) insert
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following is an example of a map?

A) { (J, Jane), (B, Bill), (S, Sam), (B1, Bob), (B, Bill) }
B) { (J, Jane), (B, Bill), (S, Sam), (B1, Bob), (B2, Bill) }
C) { (J, Jane), (B, Bill), (S, Sam), (B1, Bob), (J, Jane) }
D) { (S, Sam), (B, Bill), (S, Sam), (B1, Bob), (B2, Bill) }
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
24
The union of two sets A, B is a(n) ____.

A) set whose elements belong to both A and B
B) set whose elements belong to A but not to B
C) set where every element of A is also an element of B
D) set whose elements belong either to A or B or to both A and B
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
25
The following is an algorithm for ____.
Compute the index by taking the item's hashCode() % table.length.
If table[index] is null
The item is not in the table.
Else if table[index] is equal to the item
The item is in the table.
Else
Continue to search the table by incrementing the index until either the item is found or a null entry is found.

A) rehashing
B) accessing an item in a hash table
C) deleting an item in a hash table
D) inserting an item in a hash table
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
26
A NavigableSet (NavigableMap) allows the programmer to create _____________ of a Set (Map).
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
27
A NavigableSet (NavigableMap) can be traversed in reverse order.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 27 flashcards in this deck.