View Assessment Result: Multiple Choice Quiz 11



Your performance was as follows:

1.
Suppose hash() is a hash function. The main idea behind hashing is to use a key k to store a value v in which position of a table?

(a) hash(v)
(b) hash(k,v)
(c) hash() (a random position computed by the hash function using k)
(d) hash(k)

Correct answer is (d)

Your score on this question is: 0.00

Feedback:
   See section 2.4.1 of the course notes.
   (b) No Feedback



2.
In the context of hashing, what is meant by a collision?

(a) Two different keys hash to the same slot.
(b) The hash function returns a value larger than the table size.
(c) Two key/value pairs have the same value.
(d) The insertion algorithm cannot find an empty slot in the table.

Correct answer is (a)

Your score on this question is: 10.00

Feedback:
   See section 2.4.1 of the course notes.
   (a) No Feedback



3.
If a hash table of size m contains n items, what is the load factor of the table?

(a) n/m
(b) m - n
(c) m/n
(d) n + m

Correct answer is (a)

Your score on this question is: 10.00

Feedback:
   See section 2.4.1 of the course notes.
   (a) No Feedback



4.
Which of the following is true about a good hash function?

(a) It should never output a prime number.
(b) It should produce apparently random values for given items.
(c) It should produce small outputs for small inputs.
(d) It should only output prime numbers.

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 2.4.1 of the course notes.
   (b) No Feedback



5.
Which of the following indicates the reaction time, in general, for searching in an open addressing hash table of size 1,000,000 with a load factor of 0.9?

(a) It may fail to find an element that is present.
(b) It will be noticeably slow.
(c) It may "find" an element that is no longer there.
(d) It will be almost instantaneous.

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 2.4.1 of the course notes.
   (b) No Feedback



6.
Which of the following indicates the reaction time, in general, for searching in a chaining hash table of size 1,000,000 with a load factor of 0.9?

(a) It may "find" an element that is no longer there.
(b) It will be noticeably slow.
(c) It may fail to find an element that is present.
(d) It will be almost instantaneous.

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 2.4.1 of the course notes.
   (d) No Feedback



7.
In searching for an entry with key k in an open addressing hash table, the slot p = hash(k) is computed, after which it is necessary to

(a) traverse a linked list to check if any entry there has key k
(b) check only if the entry in slot p has key k
(c) compute p + k to find the right position for the entry
(d) check if the entry in slot p has key k, then p+1 if necessary, then p+2, and so forth.

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 2.4.1 of the course notes.
   (d) No Feedback



8.
Which of the following correctly indicates where keys and associated values are stored in hash tables when open addressing is used?

(a) Each key is stored in a slot in the table, and the associated value is stored in one of the slots that follow.
(b) The keys are stored in the list header, and the associated values are stored in linked lists.
(c) The values are stored in a slot in the table, and keys are stored in the slots that follow.
(d) Each key/value pair is stored in the table.

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 2.4.1 of the course notes.
   (d) No Feedback



9.
The appropriate return type for a search function on a chaining hash table is

(a) a Boolean
(b) an iterator
(c) a list node
(d) a pair consisting of a Boolean and an iterator

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 2.4.1 of the course notes.
   (d) No Feedback



10.

Consider the following definition of a function hash.

   size_t  hash( const char *str )
      {
          size_t  h = 0;
          for( ; *str != '0'; str++ )
               h = h*256 + *str;
      }

What, if anything, is wrong with hash as a hash function for null-terminated strings?



(a) It is very slow to compute.
(b) It only takes into account the last few characters long strings.
(c) If the string is very long, there will be overflow.
(d) Nothing

Correct answer is (b)

Your score on this question is: 0.00

Feedback:
   See section 2.4.1 of the course notes.
   (c) No Feedback



Go to top of assessment.

Total score: 80.00