Last updated on Sep 20, 2023
Latest Hashing MCQ Objective Questions
Hashing Question 1:
The following keys 22, 28, 23, 12, and 13 are inserted into an initially empty hash table of length 9 using the hash function h(k) = k mode 9 with open addressing and linear probing. At which index is the key 13 inserted?
- 5
- 6
- 7
- 4
Answer (Detailed Solution Below)
Option 2 : 6
India's Super Teachers for all govt. exams Under One Roof
FREE
Demo Classes Available*
Enroll For Free Now
Hashing Question 1 Detailed Solution
To insert a key into a hash table using open addressing with linear probing, we follow these steps:
- Calculate the hash value of the key using the hash function.
- If the calculated index is empty, insert the key at that index.
- If the calculated index is occupied, probe linearly until an empty slot is found and insert the key at that slot.
Using the given hash function h(k) = k mod 9, we can calculate the hash value of each key as follows:
- h(22) = 22 mod 9 = 4
- h(28) = 28 mod 9 = 1
- h(23) = 23 mod 9 = 5
- h(12) = 12 mod 9 = 3
- h(13) = 13 mod 9 = 4
Steps -
- To insert the keys into the hash table using linear probing, we start by inserting key 22 at index 4.
- The next key, 28, is inserted at index 1 since index 4 is already occupied.
- The third key, 23, is inserted at index 5 since index 1 is occupied and index 4 is already occupied by key 22.
- The fourth key, 12, is inserted at index 3 since index 5 is occupied, index 1 is occupied by key 28, and index 4 is already occupied by key 22.
- Finally, when we try to insert the key 13, we calculate its hash value as h(13) = 4, which is the same as the hash value of key 22.
- Since index 4 is already occupied by key 22, we need to probe linearly to find the next available slot.
- We start at index 5 (next index after 4) and find that it is occupied by key 23.
- We continue probing linearly and find that the next available slot is index 6.Therefore, the key 13 is inserted at index 6.
- So the key 13 is inserted at index 6 in the hash table.
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
Hashing Question 2:
A hash table with 10 buckets with one slot per bucket is depicted in fig. The symbols, S1 and S7 are initially entered using a hashing function with linear probing. The maximum number of comparisons needed in searching an item that is not present is
- 4
- 5
- 6
- 3
Answer (Detailed Solution Below)
Option 2 : 5
Hashing Question 2 Detailed Solution
Linear Probing:In this technique, a hash table is searched for an element linearly. If the position is already occupied, it will check the next position for the element.
- The searching can start from any of the indexes, so we have to consider the index which will cover the maximum number of elements.
- If we consider index 8, we can see that we can cover indices 8, 9, 0, and 1.
- Linear probing will search for all these 4 indices which will need a comparison.
- Then it will compare the next index, where it will find the position to be empty.
- Hence, total 4 + 1 = 5 comparisons are needed.
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
Hashing Question 3:
In which of the following hash functions, do consecutive keys map to consecutive hash values?
- Division method
- Multiplication method
- Folding method
- Mid - square method
Answer (Detailed Solution Below)
Option 1 : Division method
Hashing Question 3 Detailed Solution
The correct solution is 'option 1'.
Key Points
The method of division is unfavorable because the hash table maps the consecutive keys to consecutive hash values. This results in poor efficiency.
Hence, the correct answer is theDivision method.
Additional Information
Mid - square method:
The key is squared and the address is selected from the middle of the result.
Folding method:
The key is divided into parts whose sizes match the size of the required address. Then the parts are added to obtain the address.
Multiplication method:
A hash function that uses the first p bits of the key times an irrational number.
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
Hashing Question 4:
The physical location of a record is determined by a mathematical formula that transforms a file key into a record location is:
- B – Tree file
- Hashed File
- Indexed File
- sequential File
Answer (Detailed Solution Below)
Option 2 : Hashed File
Hashing Question 4 Detailed Solution
Concept:
Hashing is file organization method which provides very fast access to records under certain search conditions. The organization is usually called a hash file. A hash function is used to derive the physical location of a record.
Explanation:
Search condition in this is a equality condition on a single field called hash field. Hash field is a key field of the file in which case it is called hash key. The idea behind hashing is to provide a function h called hash function which is applied to the hash field value of record and yields the address of the disk block in which record is stored.
A search for the record within the block can be carries out in a main memory buffer.
Hash function for a record will be as : h(k) = k mod m where k is the field value.
Two types of hashing:
1) Internal hashing: It is used whenever a group of record is accessed exclusively by using the value of one field. It is implemented by using a hash table through the use of array of records and a hash function.
2) External hashing: It is used for dynamically growing files. Hashing for disk files is called as external hashing. In this, target address is made of buckets each of which holds multiple records.
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
Hashing Question 5:
In a Hierarchical database, a hashing function is used to locate the _______
- Collision
- Root
- Foreign Key
- Records
Answer (Detailed Solution Below)
Option 2 : Root
Hashing Question 5 Detailed Solution
Concept:
A data model is a collection of concepts that can be used to describe the structure of a database and provides the necessary means to achieve the abstraction. Types of data model are : hierarchical data model, network data model and relational model.
Explanation:
Hierarchical data model: In this data model, data is organized in the form of tree in which nodes represent the records and branches of tree represent the fields. Parent node or root of three have connection with its child nodes.
During search operation in this data model, search takes place from root and then moves to the children to reach the specific record. That means, searching always starts from root. If we use hashing function for the search operation than hashing function will locate the root of the model.
Diagram for hierarchical database model:
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
Top Hashing MCQ Objective Questions
Given a hash table 𝑇 with 25 slots that stores 2000 elements, the load factor 𝛼 for 𝑇 is _________.
Answer (Detailed Solution Below) 80
Hashing Question 6 Detailed Solution
Download Solution PDFData:
number of slots = 25
number of elements = 2000
Formula:
\({\rm{Load\;factor}}\left( {\rm{\alpha }} \right) = \frac{{{\rm{number\;of\;elements}}}}{{{\rm{number\;of\;slots}}}}{\rm{\;}}\)
Calculation:
\({\rm{Load\;factor}}\left( {\rm{\alpha }} \right) = \frac{{2000}}{{25}} = 80{\rm{\;}}\)
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
A hash table with 10 buckets with one slot per bucket is depicted in fig. The symbols, S1 and S7 are initially entered using a hashing function with linear probing. The maximum number of comparisons needed in searching an item that is not present is
- 4
- 5
- 6
- 3
Answer (Detailed Solution Below)
Option 2 : 5
Hashing Question 7 Detailed Solution
Download Solution PDFLinear Probing:In this technique, a hash table is searched for an element linearly. If the position is already occupied, it will check the next position for the element.
- The searching can start from any of the indexes, so we have to consider the index which will cover the maximum number of elements.
- If we consider index 8, we can see that we can cover indices 8, 9, 0, and 1.
- Linear probing will search for all these 4 indices which will need a comparison.
- Then it will compare the next index, where it will find the position to be empty.
- Hence, total 4 + 1 = 5 comparisons are needed.
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
In a Hierarchical database, a hashing function is used to locate the _______
- Collision
- Root
- Foreign Key
- Records
Answer (Detailed Solution Below)
Option 2 : Root
Hashing Question 8 Detailed Solution
Download Solution PDFConcept:
A data model is a collection of concepts that can be used to describe the structure of a database and provides the necessary means to achieve the abstraction. Types of data model are : hierarchical data model, network data model and relational model.
Explanation:
Hierarchical data model: In this data model, data is organized in the form of tree in which nodes represent the records and branches of tree represent the fields. Parent node or root of three have connection with its child nodes.
During search operation in this data model, search takes place from root and then moves to the children to reach the specific record. That means, searching always starts from root. If we use hashing function for the search operation than hashing function will locate the root of the model.
Diagram for hierarchical database model:
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
In which of the following hash functions, do consecutive keys map to consecutive hash values?
- Division method
- Multiplication method
- Folding method
- Mid - square method
Answer (Detailed Solution Below)
Option 1 : Division method
Hashing Question 9 Detailed Solution
Download Solution PDFThe correct solution is 'option 1'.
Key Points
The method of division is unfavorable because the hash table maps the consecutive keys to consecutive hash values. This results in poor efficiency.
Hence, the correct answer is theDivision method.
Additional Information
Mid - square method:
The key is squared and the address is selected from the middle of the result.
Folding method:
The key is divided into parts whose sizes match the size of the required address. Then the parts are added to obtain the address.
Multiplication method:
A hash function that uses the first p bits of the key times an irrational number.
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
The physical location of a record is determined by a mathematical formula that transforms a file key into a record location is:
- B – Tree file
- Hashed File
- Indexed File
- sequential File
Answer (Detailed Solution Below)
Option 2 : Hashed File
Hashing Question 10 Detailed Solution
Download Solution PDFConcept:
Hashing is file organization method which provides very fast access to records under certain search conditions. The organization is usually called a hash file. A hash function is used to derive the physical location of a record.
Explanation:
Search condition in this is a equality condition on a single field called hash field. Hash field is a key field of the file in which case it is called hash key. The idea behind hashing is to provide a function h called hash function which is applied to the hash field value of record and yields the address of the disk block in which record is stored.
A search for the record within the block can be carries out in a main memory buffer.
Hash function for a record will be as : h(k) = k mod m where k is the field value.
Two types of hashing:
1) Internal hashing: It is used whenever a group of record is accessed exclusively by using the value of one field. It is implemented by using a hash table through the use of array of records and a hash function.
2) External hashing: It is used for dynamically growing files. Hashing for disk files is called as external hashing. In this, target address is made of buckets each of which holds multiple records.
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
Hashing Question 11:
Given a hash table 𝑇 with 25 slots that stores 2000 elements, the load factor 𝛼 for 𝑇 is _________.
Answer (Detailed Solution Below) 80
Hashing Question 11 Detailed Solution
Data:
number of slots = 25
number of elements = 2000
Formula:
\({\rm{Load\;factor}}\left( {\rm{\alpha }} \right) = \frac{{{\rm{number\;of\;elements}}}}{{{\rm{number\;of\;slots}}}}{\rm{\;}}\)
Calculation:
\({\rm{Load\;factor}}\left( {\rm{\alpha }} \right) = \frac{{2000}}{{25}} = 80{\rm{\;}}\)
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
Hashing Question 12:
A hash table with 10 buckets with one slot per bucket is depicted in fig. The symbols, S1 and S7 are initially entered using a hashing function with linear probing. The maximum number of comparisons needed in searching an item that is not present is
- 4
- 5
- 6
- 3
Answer (Detailed Solution Below)
Option 2 : 5
Hashing Question 12 Detailed Solution
Linear Probing:In this technique, a hash table is searched for an element linearly. If the position is already occupied, it will check the next position for the element.
- The searching can start from any of the indexes, so we have to consider the index which will cover the maximum number of elements.
- If we consider index 8, we can see that we can cover indices 8, 9, 0, and 1.
- Linear probing will search for all these 4 indices which will need a comparison.
- Then it will compare the next index, where it will find the position to be empty.
- Hence, total 4 + 1 = 5 comparisons are needed.
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
Hashing Question 13:
In a Hierarchical database, a hashing function is used to locate the _______
- Collision
- Root
- Foreign Key
- Records
Answer (Detailed Solution Below)
Option 2 : Root
Hashing Question 13 Detailed Solution
Concept:
A data model is a collection of concepts that can be used to describe the structure of a database and provides the necessary means to achieve the abstraction. Types of data model are : hierarchical data model, network data model and relational model.
Explanation:
Hierarchical data model: In this data model, data is organized in the form of tree in which nodes represent the records and branches of tree represent the fields. Parent node or root of three have connection with its child nodes.
During search operation in this data model, search takes place from root and then moves to the children to reach the specific record. That means, searching always starts from root. If we use hashing function for the search operation than hashing function will locate the root of the model.
Diagram for hierarchical database model:
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
Hashing Question 14:
The following keys 22, 28, 23, 12, and 13 are inserted into an initially empty hash table of length 9 using the hash function h(k) = k mode 9 with open addressing and linear probing. At which index is the key 13 inserted?
- 5
- 6
- 7
- 4
Answer (Detailed Solution Below)
Option 2 : 6
Hashing Question 14 Detailed Solution
To insert a key into a hash table using open addressing with linear probing, we follow these steps:
- Calculate the hash value of the key using the hash function.
- If the calculated index is empty, insert the key at that index.
- If the calculated index is occupied, probe linearly until an empty slot is found and insert the key at that slot.
Using the given hash function h(k) = k mod 9, we can calculate the hash value of each key as follows:
- h(22) = 22 mod 9 = 4
- h(28) = 28 mod 9 = 1
- h(23) = 23 mod 9 = 5
- h(12) = 12 mod 9 = 3
- h(13) = 13 mod 9 = 4
Steps -
- To insert the keys into the hash table using linear probing, we start by inserting key 22 at index 4.
- The next key, 28, is inserted at index 1 since index 4 is already occupied.
- The third key, 23, is inserted at index 5 since index 1 is occupied and index 4 is already occupied by key 22.
- The fourth key, 12, is inserted at index 3 since index 5 is occupied, index 1 is occupied by key 28, and index 4 is already occupied by key 22.
- Finally, when we try to insert the key 13, we calculate its hash value as h(13) = 4, which is the same as the hash value of key 22.
- Since index 4 is already occupied by key 22, we need to probe linearly to find the next available slot.
- We start at index 5 (next index after 4) and find that it is occupied by key 23.
- We continue probing linearly and find that the next available slot is index 6.Therefore, the key 13 is inserted at index 6.
- So the key 13 is inserted at index 6 in the hash table.
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
Hashing Question 15:
In which of the following hash functions, do consecutive keys map to consecutive hash values?
- Division method
- Multiplication method
- Folding method
- Mid - square method
Answer (Detailed Solution Below)
Option 1 : Division method
Hashing Question 15 Detailed Solution
The correct solution is 'option 1'.
Key Points
The method of division is unfavorable because the hash table maps the consecutive keys to consecutive hash values. This results in poor efficiency.
Hence, the correct answer is theDivision method.
Additional Information
Mid - square method:
The key is squared and the address is selected from the middle of the result.
Folding method:
The key is divided into parts whose sizes match the size of the required address. Then the parts are added to obtain the address.
Multiplication method:
A hash function that uses the first p bits of the key times an irrational number.
India’s #1 Learning Platform
Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes
Trusted by 4.9 Crore+ Students
Exam Preparation
Simplified
Learn, practice, analyse and improve
Trusted by 4.9 Crore+ Students
Related MCQ
I'm an expert in database management systems (DBMS), file organization, and indexing. My expertise extends to hashing techniques, including open addressing with linear probing. Let me provide information related to the concepts used in the article you shared.
Hashing Question 1:
The keys 22, 28, 23, 12, and 13 are inserted into a hash table of length 9 using the hash function h(k) = k mod 9 with open addressing and linear probing. The key 13 is inserted at index 6.
Hashing Question 2:
A hash table with 10 buckets, one slot per bucket, is depicted. Symbols S1 and S7 are initially entered using a hashing function with linear probing. The maximum number of comparisons needed to search for an item that is not present is 5.
Hashing Question 3:
Consecutive keys map to consecutive hash values in the Division method of hashing.
Hashing Question 4:
The physical location of a record is determined by a mathematical formula in Hashed File organization.
Hashing Question 5:
In a Hierarchical database, a hashing function is used to locate the Root.
Hashing Question 6:
Given a hash table T with 25 slots storing 2000 elements, the load factor α for T is 80.
Hashing Question 7:
In a hash table with 10 buckets and one slot per bucket, linear probing results in a maximum of 5 comparisons when searching for an item that is not present.
Hashing Question 8:
In a Hierarchical database, a hashing function is used to locate the Root.
Hashing Question 9:
Consecutive keys map to consecutive hash values in the Division method of hashing.
Hashing Question 10:
The physical location of a record is determined by a mathematical formula in Hashed File organization.
Hashing Question 11:
Given a hash table T with 25 slots storing 2000 elements, the load factor α for T is 80.
Hashing Question 12:
In a hash table with 10 buckets and one slot per bucket, linear probing results in a maximum of 5 comparisons when searching for an item that is not present.
Hashing Question 13:
In a Hierarchical database, a hashing function is used to locate the Root.
Hashing Question 14:
The key 13 is inserted at index 6 in the hash table using open addressing with linear probing.
Hashing Question 15:
Consecutive keys map to consecutive hash values in the Division method of hashing.
If you have any specific questions or need more details on any of these concepts, feel free to ask!