Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Consider the hash table of size seven, with s... Start Learning for Free
Consider the hash table of size seven, with starting index zero, and a hash function (3x + 4) mod 7. Assuming the has 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 dosed hashing?
Note that - denotes an empty location in the table
  • a)
    8, 10
  • b)
    1, 8, 10, -, -, 3
  • c)
    1 , 3
  • d)
    1,10, 8, 3
Correct answer is option 'B'. Can you explain this answer?
Verified Answer
Consider the hash table of size seven, with starting index zero, and a...
Size of hash table = 7
h(x) = (3x + 4) mod 7
h(1) =. (3.1 + 4) mod 7 = 7 mod 7 
= 0; insert at 0th location.
h(3) = (3.3 + 4) mod 7 = 13 mod 7
= 6; insert at 6th location
h(8) = (3.8 + 4) mod 7 = 28 mod 7
= 0; 0th position is already filled by element 3 so insert 8 at next free location which is 1st position
h(10) = (3.10 + 4) mod 7 = 34 mod 7 = 6
but 6th position is already filled with the element 3 so insert 10 at next free location which is 2nd position
View all questions of this test
Most Upvoted Answer
Consider the hash table of size seven, with starting index zero, and a...
Hash table and Hash Function
A hash table is a data structure that stores key-value pairs. The keys are hashed using a hash function to generate an index into the table, where the corresponding value is stored. The hash function takes a key as input and returns an index that maps to a slot in the hash table.

Solution
Given hash function is (3x + 4) mod 7. We need to insert the sequence 1, 3, 8, 10 into the hash table using closed hashing or open addressing.

Closed Hashing
In closed hashing, when a collision occurs, we search for the next available slot in the hash table until we find an empty slot. The most common methods for open addressing include linear probing, quadratic probing, and double hashing.

Using the given hash function, we can compute the hash values for the given keys as follows:

Hash(1) = (3*1 + 4) mod 7 = 0
Hash(3) = (3*3 + 4) mod 7 = 2
Hash(8) = (3*8 + 4) mod 7 = 2
Hash(10) = (3*10 + 4) mod 7 = 0

Inserting the keys using closed hashing, we get:

1. Insert key 1:
Hash(1) = 0, Table[0] = 1

2. Insert key 3:
Hash(3) = 2, Table[2] = 3

3. Insert key 8:
Hash(8) = 2, Table[2] is occupied, so we probe for the next available slot:
Hash(8) + 1 = 3, Table[3] = 8

4. Insert key 10:
Hash(10) = 0, Table[0] is occupied, so we probe for the next available slot:
Hash(10) + 1 = 1, Table[1] = 10

Final Hash Table
The final hash table with the given keys using closed hashing is:

Table[0] = 1
Table[1] = 10
Table[2] = 3
Table[3] = 8
Table[4] = -
Table[5] = -
Table[6] = -

Therefore, the contents of the table when the sequence 1, 3, 8, 10 is inserted into the table using closed hashing is 1, 10, 3, 8, -, -, - which is option B.
Explore Courses for Computer Science Engineering (CSE) exam

Similar Computer Science Engineering (CSE) Doubts

Top Courses for Computer Science Engineering (CSE)

Consider the hash table of size seven, with starting index zero, and a hash function (3x+ 4) mod 7. Assuming the has 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 dosed hashing?Note that - denotes an empty location in the tablea)8, 10b)1, 8, 10, -, -, 3c)1 , 3d)1,10, 8, 3Correct answer is option 'B'. Can you explain this answer?
Question Description
Consider the hash table of size seven, with starting index zero, and a hash function (3x+ 4) mod 7. Assuming the has 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 dosed hashing?Note that - denotes an empty location in the tablea)8, 10b)1, 8, 10, -, -, 3c)1 , 3d)1,10, 8, 3Correct answer is option 'B'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Consider the hash table of size seven, with starting index zero, and a hash function (3x+ 4) mod 7. Assuming the has 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 dosed hashing?Note that - denotes an empty location in the tablea)8, 10b)1, 8, 10, -, -, 3c)1 , 3d)1,10, 8, 3Correct answer is option 'B'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider the hash table of size seven, with starting index zero, and a hash function (3x+ 4) mod 7. Assuming the has 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 dosed hashing?Note that - denotes an empty location in the tablea)8, 10b)1, 8, 10, -, -, 3c)1 , 3d)1,10, 8, 3Correct answer is option 'B'. Can you explain this answer?.
Solutions for Consider the hash table of size seven, with starting index zero, and a hash function (3x+ 4) mod 7. Assuming the has 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 dosed hashing?Note that - denotes an empty location in the tablea)8, 10b)1, 8, 10, -, -, 3c)1 , 3d)1,10, 8, 3Correct answer is option 'B'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Consider the hash table of size seven, with starting index zero, and a hash function (3x+ 4) mod 7. Assuming the has 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 dosed hashing?Note that - denotes an empty location in the tablea)8, 10b)1, 8, 10, -, -, 3c)1 , 3d)1,10, 8, 3Correct answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider the hash table of size seven, with starting index zero, and a hash function (3x+ 4) mod 7. Assuming the has 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 dosed hashing?Note that - denotes an empty location in the tablea)8, 10b)1, 8, 10, -, -, 3c)1 , 3d)1,10, 8, 3Correct answer is option 'B'. Can you explain this answer?, a detailed solution for Consider the hash table of size seven, with starting index zero, and a hash function (3x+ 4) mod 7. Assuming the has 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 dosed hashing?Note that - denotes an empty location in the tablea)8, 10b)1, 8, 10, -, -, 3c)1 , 3d)1,10, 8, 3Correct answer is option 'B'. Can you explain this answer? has been provided alongside types of Consider the hash table of size seven, with starting index zero, and a hash function (3x+ 4) mod 7. Assuming the has 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 dosed hashing?Note that - denotes an empty location in the tablea)8, 10b)1, 8, 10, -, -, 3c)1 , 3d)1,10, 8, 3Correct answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider the hash table of size seven, with starting index zero, and a hash function (3x+ 4) mod 7. Assuming the has 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 dosed hashing?Note that - denotes an empty location in the tablea)8, 10b)1, 8, 10, -, -, 3c)1 , 3d)1,10, 8, 3Correct answer is option 'B'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev