Quiz 6

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Consider the hash function h(k) = k mod m Which of the following is a good choice for the table size, m?

127

Insert keys 44, 45, 79, 55, 91, 18, 63 -- in that order -- into a hash table of size 7 with collision resolution implemented using open addressing. Assume that linear probing is used to find an open position, i.e., h(k, i) = (k + i) mod 7, where 0 <= i < 7, is the ith probe. That is, the first probe is at position (k+0) mod 7, the second at (k+1) mod 7, and so on. At what position will key 18 be inserted?

5

Suppose that the keys 5, 4, 6, 1, and 2 -- in that order -- are inserted into hash table of size 3 with hash function h(k) = k mod 3. If collisions are resolved using separate chaining, what are the values of a, b, c, d, and e, respectively, in the given image?

6, 1, 4, 2, 5

The multiplication method for creating hash functions operates in two steps. First, we multiply the key k by a constant A in the range 0 < A < 1 and extract the fractional part of kA. Then, we multiply this value by m and take the floor of the result. In short, the hash function is h(k)=⌊m(kAmod1)⌋ where kAmod1 means the fractional part of kA, that is, kA−⌊kA⌋. Suppose k=123456, m=16384, and A = 2654435769/232. What is the value of h(k)?

67.1875 Between 60 and 70

Which of the following statements are true regarding direct address tables? Statement 1: If the universe U of keys is large, storing a table of size |U| may be impractical. Statement 2: Often, most of the space allocated to table T is wasted as the set K of keys actually stored is small.

Both the statements are true

Select all statements that are true about hash tables:

Collisions can happen even when |K| <= m where K is the set of keys and m is the size of hash table

Which of the following is a collision resolution technique? Select all correct answers.

Seperate chaining

Consider the following function to traverse a linked list and print each element of it. void traverse(struct Node *head){while (head->next != NULL){printf("%d ", head->data);head = head->next;}} Which of the following statements are true? Select all the correct answers

The function may crash when the linked list is empty The function doesn't print the last node when the linked list is not empty

Select all statements that are true.

The load factor is the average number of elements stored in a chain alpha = n/mew, is the load factor of a hash table where n is the number of keys in the table and m is the table size α can be equal to one α can be greater than one αcan be less than one

Select all characteristics of a "good" hash function.

To choose a good hash function, we really should know something about the probability distribution from which the keys are drawn The division method for creating hash functions is a good heuristic method

True or false: A hash table is a generalization of an ordinary array where a function of the key is used as the index instead of using the key as the index directly.

True

True or false: The worst-case behaviour of hashing with separate chaining is terrible: All n keys hash to the same position, creating a list (chain) of length n.

True

The assumption of simple uniform hashing means that any given element is equally likely to hash into any of the m positions of the table, independently of where any other element has hashed to.

Under this assumption, an unsuccessful search takes average-case time O(α), where α is the load factor of the hash table

Insert keys 7, 10, 25, 12, 17, 34 -- in that order -- into a hash table of size 7 with collision resolution implemented using open addressing. Assume that linear probing is used to find an open position, i.e., h(k, i) = (k + i) mod 7, where 0 <= i < 7, is the ith probe. That is, the first probe is at position (k+0) mod 7, the second at (k+1) mod 7, and so on. Select the option that represents the state of the hash table after all keys are inserted.

[7, 34, EMPTY, 10, 25, 12, 17]

In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is _______ ? log2⁡n−1

n


संबंधित स्टडी सेट्स

Biology chapter 7 photosynthesis

View Set

Biology Of The Cell - prac test 1

View Set

Lab Simulation 7-2: Practice Communication between a Virtual Machine and a Host: Network +

View Set

NURS 2050 Maternal Child Health EXAM 1 Practice questions

View Set