Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

101.

What can be the value of m in the division method?(a) Any prime number(b) Any even number(c) 2^p – 1(d) 2^pI want to ask this question from Hash Tables in section Hash Tables of Data Structures & Algorithms II have been asked this question in unit test.

Answer»

Correct option is (a) Any prime number

Easy explanation - A prime number not too CLOSE to an exact power of 2 is OFTEN a good choice for m since it REDUCES the number of collisions which are likely to OCCUR.

102.

What is the hash function used in the division method?(a) h(k) = k/m(b) h(k) = k mod m(c) h(k) = m/k(d) h(k) = mmod kMy question comes from Hash Tables topic in portion Hash Tables of Data Structures & Algorithms II have been asked this question in quiz.

Answer»

Correct choice is (b) H(k) = k MOD m

For explanation: In division method for creating hash functions,k keys are mapped into ONE of m SLOTS by TAKING the reminder of k divided by m.

103.

A good hash approach is to derive the hash value that is expected to be dependent of any patterns that might exist in the data.(a) True(b) FalseThis interesting question is from Hash Tables topic in portion Hash Tables of Data Structures & Algorithms IThis question was addressed to me in final exam.

Answer»

Correct answer is (B) False

The BEST I can EXPLAIN: A hash value is expected to be UNRELATED or independent of any patterns in the distribution of keys.

104.

Which hash function satisfies the condition of simple uniform hashing?(a) h(k) = lowerbound(km)(b) h(k)= upperbound(mk)(c) h(k)= lowerbound(k)(d) h(k)= upperbound(k)I would like to ask this question from Hash Tables in chapter Hash Tables of Data Structures & Algorithms II got this question during an interview.

Answer»

correct OPTION is: (a) h(K) = lowerbound(km)

If the keys are KNOWN to be random real numbers k independently and UNIFORMLY distributed in the range 0<=k<=1, the HASH function which satisfies the condition of simple uniform hashing is

h(k)= lowerbound(km).

105.

Which scheme uses a randomization approach?(a) hashing by division(b) hashing by multiplication(c) universal hashing(d) open addressingMy question comes from Hash Tables topic in chapter Hash Tables of Data Structures & Algorithms II have been asked this question in semester exam.

Answer» CORRECT OPTION is (c) universal hashing

The BEST I can explain: Universal hashing SCHEME uses a randomization approach whereas hashing by division and hashing by multiplication are heuristic in nature.
106.

What is the formula used in quadratic probing?(a) Hash key = key mod table size(b) Hash key=(hash(x)+F(i)) mod table size(c) Hash key=(hash(x)+F(i^2)) mod table size(d) H(x) = x mod 17The above asked question is from Hash Tables topic in portion Hash Tables of Data Structures & Algorithms II had been asked this question during an online exam.

Answer»

Right ANSWER is (c) Hash key=(hash(X)+F(i^2)) mod table size

Explanation: Hash key=(hash(x)+F(i^2)) mod table size is the formula for QUADRATIC probing. Hash key = (hash(x)+F(i)) mod table size is the formula for LINEAR probing.

107.

Which of the following techniques offer better cache performance?(a) Quadratic probing(b) Linear probing(c) Double hashing(d) RehashingMy question is based upon Hash Tables topic in portion Hash Tables of Data Structures & Algorithms II got this question in quiz.

Answer»

Correct choice is (B) LINEAR probing

For explanation: Linear probing OFFERS BETTER cache PERFORMANCE than quadratic probing and also it preserves locality of reference.

108.

Which among the following is the best technique to handle collision?(a) Quadratic probing(b) Linear probing(c) Double hashing(d) Separate chainingThis question is from Hash Tables topic in division Hash Tables of Data Structures & Algorithms IThis question was addressed to me in my homework.

Answer»

The CORRECT answer is (a) Quadratic PROBING

Easy explanation - Quadratic probing HANDLES primary COLLISION occurring in the linear probing METHOD. Although secondary collision occurs in quadratic probing, it can be removed by extra multiplications and divisions.

109.

How many constraints are to be met to successfully implement quadratic probing?(a) 1(b) 2(c) 3(d) 4This interesting question is from Hash Tables in division Hash Tables of Data Structures & Algorithms IThe question was posed to me in an internship interview.

Answer»

Correct OPTION is (b) 2

For explanation: 2 requirements are to be MET with respect to table size. The table size should be a PRIME NUMBER and the table size should not be more than half FULL.

110.

Which of the following is the correct function definition for quadratic probing?(a) F(i)=i^2(b) F(i)=i(c) F(i)=i+1(d) F(i)=i^2+1The doubt is from Hash Tables topic in portion Hash Tables of Data Structures & Algorithms II have been asked this question in exam.

Answer»

The CORRECT option is (a) F(i)=i^2

Best EXPLANATION: The FUNCTION of QUADRATIC probing is defined as F(i)=i^2. The function of linear probing is defined as F(i)=i.

111.

In quadratic probing, if the table size is prime, a new element cannot be inserted if the table is half full.(a) True(b) FalseThe above asked question is from Hash Tables in portion Hash Tables of Data Structures & Algorithms IThis question was posed to me in examination.

Answer»

The correct ANSWER is (b) False

The BEST EXPLANATION: In quadratic probing, if the table SIZE is prime, we can insert a new ELEMENT even though table is exactly half filled. We can’t insert element if table size is more than half filled.

112.

What kind of deletion is implemented by hashing using open addressing?(a) active deletion(b) standard deletion(c) lazy deletion(d) no deletionMy query is from Hash Tables in division Hash Tables of Data Structures & Algorithms II have been asked this question by my college director while I was bunking the class.

Answer»

Correct option is (C) lazy deletion

Explanation: STANDARD deletion cannot be performed in an open addressing hash table, because the cells might have caused collision. HENCE, the hash tables IMPLEMENT lazy deletion.

113.

Quadratic probing overcomes primary collision.(a) True(b) FalseThis intriguing question originated from Hash Tables in chapter Hash Tables of Data Structures & Algorithms II got this question in an online interview.

Answer»

Correct option is (a) True

The best EXPLANATION: QUADRATIC PROBING can overcome primary collision that OCCURS in linear probing but a secondary collision occurs in quadratic probing.

114.

Which of the following schemes does quadratic probing come under?(a) rehashing(b) extended hashing(c) separate chaining(d) open addressingThis key question is from Hash Tables in chapter Hash Tables of Data Structures & Algorithms II have been asked this question in an internship interview.

Answer»

Correct option is (d) open addressing

To explain: Quadratic PROBING comes under open addressing SCHEME to RESOLVE collisions in hash tables.

115.

What is the formula to find the expected number of probes for an unsuccessful search in linear probing?(a) \(\frac{1}{2} \frac{1+1}{(1-⅄)}\)(b) \(\frac{1}{2}\frac{1+1}{(1-⅄)^2}\)(c) \(\frac{1}{2}\frac{1+1}{(1+⅄)}\)(d) \(\frac{1}{2}\frac{1+1}{(1+⅄)(1-⅄)}\)My question is based upon Hash Tables in section Hash Tables of Data Structures & Algorithms II got this question during an online interview.

Answer»

The CORRECT option is (b) \(\frac{1}{2}\frac{1+1}{(1-⅄)^2}\)

The BEST I can explain: The mathematical FORMULA for calculating the number of probes for an UNSUCCESSFUL search is \(\frac{1}{2}\frac{1+1}{(1-⅄)^2}\). For INSERTION, it is \(\frac{1}{2} \frac{1+1}{(1-⅄)}\).

116.

Hashing can be used in online spelling checkers.(a) True(b) FalseMy doubt stems from Hash Tables topic in division Hash Tables of Data Structures & Algorithms II had been asked this question in homework.

Answer» RIGHT choice is (a) True

The best I can EXPLAIN: If MISSPELLING detection is important, an entire dictionary can be pre-hashed and words can be CHECKED in constant TIME.
117.

What is the hash function used in linear probing?(a) H(x)= key mod table size(b) H(x)= (key+ F(i^2)) mod table size(c) H(x)= (key+ F(i)) mod table size(d) H(x)= X mod 17I'd like to ask this question from Hash Tables in division Hash Tables of Data Structures & Algorithms IThis question was posed to me during an online exam.

Answer»

Correct CHOICE is (c) H(x)= (key+ F(i)) mod table size

To explain: The hash FUNCTION used in linear probing is defined to be H(x)= (key+ F(i)) mod table size where i=0,1,2,3,…,N.

118.

___________is not a theoretical problem but actually occurs in real implementations of probing.(a) Hashing(b) Clustering(c) Rehashing(d) CollisionThis question is from Hash Tables topic in section Hash Tables of Data Structures & Algorithms II had been asked this question in an online interview.

Answer» CORRECT CHOICE is (b) Clustering

Easiest EXPLANATION - Clustering is not a theoretical PROBLEM but it occurs in implementations of hashing. Rehashing is a kind of hashing.
119.

Which of the following is the correct function definition for linear probing?(a) F(i)= 1(b) F(i)=i(c) F(i)=i^2(d) F(i)=i+1I want to ask this question from Hash Tables topic in section Hash Tables of Data Structures & Algorithms IThis question was addressed to me in final exam.

Answer»

Right ANSWER is (B) F(i)=i

Easiest explanation - The function USED in linear probing is defined as, F(i)=I where i=0,1,2,3….,n.

120.

In linear probing, the cost of an unsuccessful search can be used to compute the average cost of a successful search.(a) True(b) FalseThe above asked question is from Hash Tables topic in section Hash Tables of Data Structures & Algorithms II have been asked this question in quiz.

Answer»

Right choice is (a) True

Best EXPLANATION: Using random COLLISION RESOLUTION ALGORITHM, the cost of an unsuccessful search can be used to compute the average cost of a successful search.

121.

Which of the following is not a collision resolution strategy for open addressing?(a) Linear probing(b) Quadratic probing(c) Double hashing(d) RehashingI need to ask this question from Hash Tables in division Hash Tables of Data Structures & Algorithms II got this question at a job interview.

Answer»

The correct option is (d) Rehashing

Best explanation: LINEAR probing, quadratic probing and DOUBLE hashing are all collision resolution STRATEGIES for open addressing whereas rehashing is a different TECHNIQUE.

122.

What is the load factor for an open addressing technique?(a) 1(b) 0.5(c) 1.5(d) 0I want to ask this question from Hash Tables topic in section Hash Tables of Data Structures & Algorithms IThis question was posed to me during an interview.

Answer» RIGHT answer is (b) 0.5

The best EXPLANATION: The load factor for an OPEN addressing TECHNIQUE should be 0.5. For separate CHAINING technique, the load factor is 1.
123.

How many probes are required on average for insertion and successful search?(a) 4 and 10(b) 2 and 6(c) 2.5 and 1.5(d) 3.5 and 1.5My question comes from Hash Tables topic in portion Hash Tables of Data Structures & Algorithms IThe question was asked in an online interview.

Answer»

The correct option is (C) 2.5 and 1.5

For explanation: Using FORMULA, the average number of probes required for INSERTION is 2.5 and for a SUCCESSFUL search, it is 1.5.

124.

Which of the following problems occur due to linear probing?(a) Primary collision(b) Secondary collision(c) Separate chaining(d) Extendible hashingMy doubt stems from Hash Tables in portion Hash Tables of Data Structures & Algorithms II had been asked this question in unit test.

Answer»

The CORRECT ANSWER is (a) Primary collision

Explanation: Primary collision occurs due to linear probing TECHNIQUE. It is overcome using a quadratic probing technique.