Data Structure Numerical Mcq SET 1


Q1) A hash table of length 10 uses open addressing with hash function h(k)=k mod 10, and linear probing. After inserting 6 values into an empty hash table, the table is as shown below.
             
Which one of the following choices gives a possible order in which the key values could have been inserted in the table?
A
46, 42, 34, 52, 23, 33
B
34, 42, 23, 52, 33, 46
C
46, 34, 42, 23, 52, 33
D
42, 46, 33, 23, 34, 52

 


Q2) Consider a hash table of size seven, with starting index zero, and a hash function (3x + 4)mod7. Assuming the hash table is initially empty, which of the following is the contents of the table when the sequence 1, 3, 8, 10 is inserted into the table using closed hashing? Note that ‘_’ denotes an empty location in the table.

A
8, _, _, _, _, _, 10
B
1, 8, 10, _, _, _, 3
C
1, _, _, _, _, _,3
D
1, 10, 8, _, _, _, 3

Q3) Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199) and the hash function x mod 10, which of the following statements are true? i. 9679, 1989, 4199 hash to the same value ii. 1471, 6171 has to the same value iii. All elements hash to the same value iv. Each element hashes to a different value (GATE CS 2004)

A
i only
B
ii only
C
i and ii only
D
iii or iv

Q4) Consider a hash table with 100 slots. Collisions are resolved using chaining. Assuming simple uniform hashing, what is the probability that the first 3 slots are unfilled after the first 3 insertions?

A
(97 × 97 × 97)/100^3
B
(99 × 98 × 97)/100^3
C
(97 × 96 × 95)/100^3
D
(97 × 96 × 95)/(3! × 100^3)

Q5) Which of the following statement(s) is TRUE?

  1. A hash function takes a message of arbitrary length and generates a fixed length code.
  2. A hash function takes a message of fixed length and generates a code of variable length.
  3. A hash function may give the same hash value for distinct messages.

 

A
I only
B
II and III only
C
I and III only
D
II only

Q6) How many different insertion sequences of the key values using the same hash function and linear probing will result in the hash table shown above?

A
10
B
20
C
30
D
40

Q7) Which one of the following hash functions on integers will distribute keys most uniformly over 10 buckets numbered 0 to 9 for i ranging from 0 to 2020?

A
h(i) =i^2 mod 10
B
h(i) =i^3 mod 10
C
h(i) = (11 ∗ i^2) mod 10
D
h(i) = (12 ∗ i) mod 10

Q8) Given a hash table T with 25 slots that stores 2000 elements, the load factor α for T is __________

A
80
B
0.0125
C
8000
D
1.25

Q9) A program P reads in 500 integers in the range [0..100] exepresenting the scores of 500 students. It then prints the frequency of each score above 50. What would be the best way for P to store the frequencies? (GATE CS 2005)

A
An array of 50 numbers
B
An array of 100 numbers
C
An array of 500 numbers
D
A dynamically allocated array of 550 numbers

Q10) 

The minimum number of comparisons required to determine if an integer appears more than n/2 times in a sorted array of n integers is

(A) \theta(n)
(B) \theta(logn)
(C) \theta(log*n)
(D) \theta(n)
A
A
B
B
C
C
D
D

Leave a comment