What is hashing?
A) A method of data encryption
B) A process of converting data into a fixed-size value
C) A way to sort data
D) None of the above
Answer: B) A process of converting data into a fixed-size value
Which of the following is a common use of hashing?
A) Searching data
B) Storing passwords
C) Data retrieval
D) All of the above
Answer: D) All of the above
What is a hash table?
A) A collection of key-value pairs
B) A type of array
C) A type of linked list
D) None of the above
Answer: A) A collection of key-value pairs
What is the main advantage of using a hash table?
A) Sequential access
B) Fast data retrieval
C) Low memory usage
D) Simplicity
Answer: B) Fast data retrieval
What is a collision in hashing?
A) When two keys map to the same hash value
B) When a key is not found
C) When data is corrupted
D) None of the above
Answer: A) When two keys map to the same hash value
Which of the following techniques is used to resolve collisions?
A) Chaining
B) Open addressing
C) Both A and B
D) None of the above
Answer: C) Both A and B
In a hash table, what is the load factor?
A) Ratio of the number of entries to the size of the table
B) Number of collisions
C) Size of the data
D) None of the above
Answer: A) Ratio of the number of entries to the size of the table
What happens when the load factor exceeds a certain threshold in a hash table?
A) The table is resized
B) Collisions increase
C) Data is lost
D) None of the above
Answer: A) The table is resized
What is the purpose of a hash function?
A) To encrypt data
B) To create a unique index for a given key
C) To sort data
D) None of the above
Answer: B) To create a unique index for a given key
Which of the following is NOT a characteristic of a good hash function?
A) Uniform distribution
B) Fast computation
C) Easy to invert
D) Minimizes collisions
Answer: C) Easy to invert
What is open addressing in hashing?
A) Storing multiple values in the same index
B) Finding the next open slot for a key
C) Storing data in sorted order
D) None of the above
Answer: B) Finding the next open slot for a key
Which of the following is a common open addressing technique?
A) Linear probing
B) Quadratic probing
C) Double hashing
D) All of the above
Answer: D) All of the above
What is the primary disadvantage of chaining for collision resolution?
A) Increased memory usage
B) Slow retrieval times
C) Complexity
D) None of the above
Answer: A) Increased memory usage
In a hash table, if the size of the table is 10 and there are 5 entries, what is the load factor?
A) 0.5
B) 1
C) 2
D) 0.1
Answer: A) 0.5
What is the time complexity of searching for an element in an ideal hash table?
A) O(n)
B) O(log n)
C) O(1)
D) O(n log n)
Answer: C) O(1)
Which of the following hash functions is considered to be simple but not very effective?
A) Division method
B) Multiplication method
C) Universal hashing
D) None of the above
Answer: A) Division method
In hashing, what is the main problem caused by a high load factor?
A) Increased retrieval time
B) Increased storage
C) Data loss
D) None of the above
Answer: A) Increased retrieval time
What is the main purpose of a hash code?
A) To encrypt data
B) To create a unique identifier for data
C) To sort data
D) None of the above
Answer: B) To create a unique identifier for data
What is the expected time complexity for insertion in a well-designed hash table?
A) O(n)
B) O(log n)
C) O(1)
D) O(n log n)
Answer: C) O(1)
Which of the following is an example of a non-cryptographic hash function?
A) SHA-256
B) MD5
C) MurmurHash
D) HMAC
Answer: C) MurmurHash
What is the main use of cryptographic hash functions?
A) Data storage
B) Data retrieval
C) Data integrity and security
D) None of the above
Answer: C) Data integrity and security
Which of the following statements is true regarding hashing?
A) It guarantees unique keys for every value
B) It can lead to collisions
C) It uses more memory than other data structures
D) None of the above
Answer: B) It can lead to collisions
What is the effect of a poor hash function?
A) Faster retrieval
B) Increased collisions
C) Reduced memory usage
D) None of the above
Answer: B) Increased collisions
What is the primary benefit of using a hash table for data storage?
A) Easy to implement
B) Fast data access
C) Requires less memory
D) None of the above
Answer: B) Fast data access
Which method is used to compute a hash value from a key?
A) Hash algorithm
B) Hash table
C) Hash function
D) None of the above
Answer: C) Hash function
What is a hash collision resolution strategy that uses linked lists?
A) Linear probing
B) Quadratic probing
C) Chaining
D) Double hashing
Answer: C) Chaining
Which of the following scenarios can lead to poor performance in hash tables?
A) High load factor
B) Poor hash function
C) Excessive collisions
D) All of the above
Answer: D) All of the above
What is double hashing?
A) A technique that uses two hash functions to resolve collisions
B) A method of storing data twice for redundancy
C) A method of increasing the size of a hash table
D) None of the above
Answer: A) A technique that uses two hash functions to resolve collisions
Which of the following describes the chaining technique for collision resolution?
A) All elements are stored in a single list
B) Each index in the hash table points to a linked list of entries
C) The first collision is resolved by linear probing
D) None of the above
Answer: B) Each index in the hash table points to a linked list of entries
What is the time complexity for deleting an element from a hash table?
A) O(n)
B) O(log n)
C) O(1)
D) O(n log n)
Answer: C) O(1)
Which hashing technique is best suited for a dynamic dataset?
A) Static hashing
B) Dynamic hashing
C) Open addressing
D) None of the above
Answer: B) Dynamic hashing
What is the main disadvantage of open addressing?
A) Increased memory usage
B) Complexity of implementation
C) Performance degradation with high load factors
D) None of the above
Answer: C) Performance degradation with high load factors
What is a universal hashing?
A) A hash function that is used for all types of data
B) A technique that minimizes collisions for any input
C) A hashing method based on randomization
D) None of the above
Answer: C) A hashing method based on randomization
Which hash function method is commonly used in databases?
A) Division method
B) Multiplication method
C) Cryptographic hash functions
D) None of the above
Answer: B) Multiplication method
What is the purpose of rehashing?
A) To improve data security
B) To reduce the number of collisions
C) To increase the size of the hash table
D) None of the above
Answer: C) To increase the size of the hash table
Which of the following best describes a hash function?
A) It maps data of arbitrary size to fixed-size values
B) It only works with numeric data
C) It is always one-to-one
D) None of the above
Answer: A) It maps data of arbitrary size to fixed-size values
In a hash table with a capacity of 10, if the load factor is 0.8, how many entries are there?
A) 8
B) 10
C) 12
D) 6
Answer: A) 8
What is the impact of using a good hash function?
A) Reduced collisions
B) Faster access times
C) Efficient memory usage
D) All of the above
Answer: D) All of the above
Basic Concepts
Non-Linear Data Structures MCQs
Sorting and Searching Algorithms MCQs
- Data Structures MCQs 1
- Data Structures MCQs 2
- Data Structures MCQs 3
- Data Structures MCQs 4
- Data Structures MCQs 5
- Stacks Solved MCQs
- Queues MCQs
- pointer mcqs
- Array MCQs