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 hashing implementation of a set, self.index refers to the index of the chain in which the node was just located, or is -1 otherwise.
Free
(True/False)
4.9/5
(37)
Correct Answer:
True
In the code for the __iter__ method for the ArrayDict class, what is the missing code? def __iter__(self):
Cursor = 0
While cursor < len(self):
Yield self.items[cursor].key
< missing code >
Free
(Multiple Choice)
4.8/5
(49)
Correct Answer:
D
The AbstractSet class is a subclass of AbstractBag .
Free
(True/False)
4.8/5
(31)
Correct Answer:
False
In the code for the __sub__ method for the AbstractSet class, what is the missing code? def __sub__(self, other):
Difference = type(self)()
For item in self:
If not item in other:
< missing code >
Return difference
(Multiple Choice)
4.8/5
(29)
A small load factor and an array length that is a prime number increases the chances for a hashing collision.
(True/False)
4.9/5
(41)
To reduce the probability of collisions with hashes, you can decrease the array length.
(True/False)
4.7/5
(47)
Referring to the keysToIndexes function, what is the result of the following statement? keysToIndexes([ 39, 18, 4, 51, 6, 28 ], 17)
(Multiple Choice)
4.7/5
(40)
Which of the following is a subset of Set A if Set A is {19 4 26 8}?
(Multiple Choice)
4.9/5
(42)
Array-based implementations of sets and dictionaries do not perform well.
(True/False)
4.9/5
(29)
A set is similar to a bag, but it contains unique data items and additional methods.
(True/False)
4.8/5
(34)
In the implementation of the AbstractDict class, which four methods have the same implementation for all dictionaries?
(Multiple Choice)
4.7/5
(38)
In the code for the __init__ method in the Entry class or a dictionary, what is the missing code? def __init__(self, key, value):
< missing code >
Self.value = value
(Multiple Choice)
4.8/5
(32)
In the Entry class for a dictionary, comparisons are done using the value item in each entry.
(True/False)
4.8/5
(46)
Python supports multiple inheritance, so a class can have more than one parent class.
(True/False)
4.7/5
(48)
The standard Python hash function always returns a unique positive integer.
(True/False)
4.9/5
(40)
What is the performance value of the array-based implementations of sets and dictionaries?
(Multiple Choice)
4.9/5
(43)
For a key value of 93 and a hashing function of key % 46 , what is the index into the array?
(Multiple Choice)
4.8/5
(42)
In which collision-avoidance hashing strategy are the items stored in an array of linked lists in which each item's key locates the bucket where the item is to be inserted?
(Multiple Choice)
4.9/5
(39)
With a set, the difference and subset operations are not symmetric.
(True/False)
4.8/5
(28)
Showing 1 - 20 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)