Filters
Question type

Study Flashcards

The __sub__ method of the set class returns a set containing items in s1 that are not in s2.

A) True
B) False

Correct Answer

verifed

verified

In the algorithm for the __contains method of the hashing implementation of sets, what is the first step in the algorithm?


A) set foundNode to table[ index ]
B) set priorNode to foundNode
C) set index to the home index of the item
D) set foundNode to foundNode.next

E) B) and C)
F) A) and C)

Correct Answer

verifed

verified

In the code for the keysToIndexes function, what is the missing code? def keysToIndexes(keys, n) : Return < missing code >


A) list(map(lambda key: key % n, keys) )
B) list(map(lambda key: keys, key % n ) )
C) map(list(lambda key: key % n, keys) )
D) map(list(lambda key % n: keys, key) )

E) None of the above
F) B) and C)

Correct Answer

verifed

verified

For a given set s , which method returns True if item is in s , or False otherwise.


A) s.__contains__(item)
B) s.__iter__(item)
C) s = set()
D) S1.__sub__(s2)

E) A) and D)
F) B) and C)

Correct Answer

verifed

verified

A hashing function acts on a given key by returning its absolute position in an array.

A) True
B) False

Correct Answer

verifed

verified

In the hashing implementation of a dictionary, the data field of each node in a chain contains an Entry object.

A) True
B) False

Correct Answer

verifed

verified

Which of the following is the best array length to reduce the probability of collisions given the set [ 8, 6, 18, 9, 14, 23 ]?


A) 9
B) 8
C) 11
D) 12

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

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.

A) True
B) False

Correct Answer

verifed

verified

Which method in the interface for a dictionary collection returns an iterator on the key/value pairs in the dictionary?


A) keys()
B) entries()
C) pairs()
D) values()

E) None of the above
F) All of the above

Correct Answer

verifed

verified

In Python's dict type, values are inserted or replaced at a given location using the index operator {} .

A) True
B) False

Correct Answer

verifed

verified

If a hashing function runs in constant time, insertions, accesses, and removals of the associated keys are O(1).

A) True
B) False

Correct Answer

verifed

verified

Which of the following is true about sets?


A) the items in a set are arranged in order
B) the difference and subset operations on a set are symmetric
C) there are no duplicate items in a set
D) there is no standard set class in Python

E) C) and D)
F) A) and D)

Correct Answer

verifed

verified

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?


A) absolute index
B) probe index
C) zero index
D) home index

E) None of the above
F) All of the above

Correct Answer

verifed

verified

For key values of 84 and 108 and a hashing function of key % 12 , what is the result?


A) indexes of 7 and 9
B) indexes of 0 and 1
C) a collision
D) indexes of 12 and 14

E) A) and D)
F) None of the above

Correct Answer

verifed

verified

The AbstractSet class is a subclass of AbstractCollection because AbstractSet introduces new instance variables for data.

A) True
B) False

Correct Answer

verifed

verified

The entries in a dictionary consist of a key, a value, and an index.

A) True
B) False

Correct Answer

verifed

verified

Two strings that are anagrams will return a unique integer value when the sum of the ASCII values is calculated.

A) True
B) False

Correct Answer

verifed

verified

What strategy does the hashing implementation of a dictionary use?


A) a binary search tree
B) quadratic probing
C) linear probing/bucket
D) bucket/chaining

E) None of the above
F) C) and D)

Correct Answer

verifed

verified

As the density, or number of keys relative to the length of an array decreases, so does the probability of hashing collisions.

A) True
B) False

Correct Answer

verifed

verified

Which statement is true when considering a hashing strategy and the density of the keys/array length relationship?


A) as the density decreases, the probability of collisions decreases
B) as the density increases, the probability of collisions decreases
C) as the density decreases, the probability of collisions increases
D) as the density increases, the probability of collisions stays the same

E) C) and D)
F) All of the above

Correct Answer

verifed

verified

Showing 21 - 40 of 50

Related Exams

Show Answer