• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Hash Data Strcuture with Answers

Question 21

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

  • 80

  • 0.0125

  • 8000

  • 1.25

Question 22

Consider a hash table of size seven, with starting index zero, and a hash function (7x+3) mod 4. 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 ? Here “__” denotes an empty location in the table.
  • 3, 10, 1, 8, __ , __ , __
  • 1, 3, 8, 10, __ , __ , __
  • 1, __ , 3, __ , 8, __ , 10
  • 3, 10, __ , __ , 8, __ , __

Question 23

The keys 12, 18, 13, 2, 3, 23, 5 and 15 are inserted into an initially empty hash table of length 10 using open addressing with hash function h(k) = k mod 10 and linear probing. What is the resultant hash table?

[caption width="800"] [/caption]
  • A

  • B

  • C

  • D

Question 24

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. 

[caption width="800"] [/caption]

Which one of the following choices gives a possible order in which the key values could have been inserted in the table?

  • 46, 42, 34, 52, 23, 33

  • 34, 42, 23, 52, 33, 46

  • 46, 34, 42, 23, 52, 33

  • 42, 46, 33, 23, 34, 52

Question 25

Suppose we are given n keys, m hash table slots, and two simple uniform hash functions h1 and h2. Further, suppose our hashing scheme uses h1 for the odd keys and h2 for the even keys. What is the expected number of keys in a slot? 

  • [Tex]\frac{n}{2m}[/Tex]

  • [Tex]\frac{n}{m}[/Tex]

  • [Tex]\frac{m}{n}[/Tex]

  • [Tex]\frac{2n}{m}[/Tex]

Question 26

Output of given program is,

Python3
def findSymPairs(arr, row):
    hM = dict()
    for i in range(row):
        first = arr[i][0]
        sec = arr[i][1]
        if (sec in hM.keys() and hM[sec] == first):
            print("(", sec,",", first, ")")
        else:
            hM[first] = sec
        
if __name__ == '__main__':
    arr = [[0 for i in range(2)]
      for i in range(5)]
    arr[0][0], arr[0][1] = 11, 20
    arr[1][0], arr[1][1] = 30, 40
    arr[2][0], arr[2][1] = 5, 10
    arr[3][0], arr[3][1] = 40, 30
    arr[4][0], arr[4][1] = 10, 5
    findSymPairs(arr, 5)
  • (30, 40)
    (5, 10)

  • (30, 40)
    (5, 5)

  • (30, 4)
    (5, 1)

  • (3, 4)
    (5, 1)

Question 27

Which of the following are components of Hashing?

  • Key

  • Hash Function

  • Hash Table

  • All of the above

Question 28

Which is a simple form of hashing where the data is directly mapped to an index in a hash table.

  • Collision

  • Index Mapping

  • Functional Mapping

  • Hash function

Question 29

What are the applications of linear probing include:

  • Databases

  • Caching

  • Compiler Design

  • All of the above

Question 30

What are the methods to handle  collision: 

  • Separate Chaining 

  • Open Chaining 

  • Both of the above

  • None of the above

There are 30 questions to complete.

Last Updated :
Take a part in the ongoing discussion