Exam 11: Sets and Dictionaries
Exam 1: Basic Python Programming51 Questions
Exam 2: An Overview of Collections50 Questions
Exam 3: Searching, Sorting, and Complexity Analysis50 Questions
Exam 4: Arrays and Linked Structures50 Questions
Exam 5: Interfaces, Implementations, and Polymorphism50 Questions
Exam 6: Inheritance and Abstract Classes50 Questions
Exam 7: Stacks50 Questions
Exam 8: Queues50 Questions
Exam 9: Lists50 Questions
Exam 10: Trees50 Questions
Exam 11: Sets and Dictionaries50 Questions
Exam 12: Graphs50 Questions
Select questions type
In the code for the keysToIndexes function, what is the missing code? def keysToIndexes(keys, n):
Return < missing code >
(Multiple Choice)
4.8/5
(42)
If a hashing function runs in constant time, insertions, accesses, and removals of the associated keys are O(1).
(True/False)
4.8/5
(40)
As the density, or number of keys relative to the length of an array decreases, so does the probability of hashing collisions.
(True/False)
4.8/5
(28)
When considering an insertion into a set using a hash function and linear probing, which of the following is defined as the position where the item should go if the has function works perfectly?
(Multiple Choice)
4.9/5
(35)
Which of the following is the best array length to reduce the probability of collisions given the set [ 8, 6, 18, 9, 14, 23 ]?
(Multiple Choice)
4.8/5
(34)
The __sub__ method of the set class returns a set containing items in s1 that are not in s2.
(True/False)
4.7/5
(29)
Which statement is true when considering a hashing strategy and the density of the keys/array length relationship?
(Multiple Choice)
4.8/5
(34)
A hashing function acts on a given key by returning its absolute position in an array.
(True/False)
4.9/5
(41)
In the hashing implementation of a set, the Bag class is used to represent an item and a pointer to the next item in a chain.
(True/False)
4.8/5
(42)
The entries in a dictionary consist of a key, a value, and an index.
(True/False)
4.7/5
(38)
What strategy does the hashing implementation of a dictionary use?
(Multiple Choice)
4.8/5
(35)
For a given set s , which method returns True if item is in s , or False otherwise.
(Multiple Choice)
4.9/5
(45)
In the algorithm for the __contains method of the hashing implementation of sets, what is the first step in the algorithm?
(Multiple Choice)
4.9/5
(49)
In the hashing implementation of a dictionary, the data field of each node in a chain contains an Entry object.
(True/False)
4.7/5
(41)
For key values of 84 and 108 and a hashing function of key % 12 , what is the result?
(Multiple Choice)
4.9/5
(30)
In Python's dict type, values are inserted or replaced at a given location using the index operator {} .
(True/False)
4.9/5
(35)
The AbstractSet class is a subclass of AbstractCollection because AbstractSet introduces new instance variables for data.
(True/False)
4.9/5
(27)
Two strings that are anagrams will return a unique integer value when the sum of the ASCII values is calculated.
(True/False)
4.8/5
(46)
Which method in the interface for a dictionary collection returns an iterator on the key/value pairs in the dictionary?
(Multiple Choice)
5.0/5
(39)
Showing 21 - 40 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)