wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Data Structure

Total questions: 13

Worksheet time: 5mins

Name
Class
Date
1.

1. What is a hash table?

a)

a) A structure that maps values to keys

b)

b) A structure that maps keys to values

c)

c) A structure used for storage

d)

d) A structure used to implement stack and queue

2.

If several elements are competing for the same bucket in the hash table, what is it called?

a)

a) Diffusion

b)

b) Replication

c)

c) Collision

d)

d) Duplication

3.

What is direct addressing?

a)

a) Distinct array position for every possible key

b)

b) Fewer array positions than keys

c)

c) Fewer keys than array positions

d)

d) Same array position for all keys

4.

What is the search complexity in direct addressing?

a)

a) O(n)

b)

b) O(logn)

c)

c) O(nlogn)

d)

d) O(1)

5.

What is a hash function?

a)

a) A function has allocated memory to keys

b)

b) A function that computes the location of the key in the array

c)

c) A function that creates an array

d)

d) A function that computes the location of the values in the array

6.

Which of the following is not a technique to avoid a collision?

a)

a) Make the hash function appear random

b)

b) Use the chaining method

c)

c) Use uniform hashing

d)

d) Increasing hash table size

7.

7. What is the load factor?

a)

a) Average array size

b)

b) Average key size

c)

c) Average chain length

d)

d) Average hash table length

8.

If h is any hashing function and is used to hash n keys in to a table of size m, where n<=m, the expected number of collisions involving a particular key x is :

a)

a) Less than 1

b)

b) Less than n

c)

c) Less than m

d)

d) Less than n/2

9.

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)

a) 8, _, _, _, _, _, 10

b)

b) 1, 8, 10, _, _, _, 3

c)

c) 1, _, _, _, _, _,3

d)

d) 1, 10, 8, _, _, _, 3

10.

A hash table can store a maximum of 10 records, currently there are records in location 1, 3,4,7,8,9,10. The probability of a new record going into location 2, with hash functions resolving collisions by linear probing is

a)

a) 0.1

b)

b) 0.6

c)

c) 0.2

d)

d) 0.5

11.

Which of the following scenarios leads to linear running time for a random search hit in a linear-probing hash table?

a)

a) All keys hash to same index

b)

b) All keys hash to different indices

c)

c) All keys hash to an even-numbered index

d)

d) All keys hash to different even-numbered indices

12.

The hash function is

H1(k) = k % 50.

In the case of collision, the hash function used is

H(k) = (H1(k) + M x H2(k)) % 50

where H1(k) = k % 50 and H2(k) = k % 20.

M is initialized to 0 and is incremented by 1 each time a collision occurs.

This could be categorized under which of the following collision detection technique

a)

a)Linear Probing

b)

b)quadratic Probing

c)

c)Re-Hashing

d)

d)Double Hashing

13.

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

a)

a)80

b)

b)0.0125

c)

c)8000

d)

d)1.25