37 37 votes Consider a hash table of size seven, with starting index zero, and a hash function $(3x + 4)\mod 7$. 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. $8$, −, −, −, −, −, $10$ $1, 8, 10$, −, −, −, $3$ $1$, −, −, −, −, −, $3$ $1, 10, 8$, −, −, −,$ 3$ Data Structures gatecse-2007 data-structures hashing easy + – Kathleen 21.7k views answer comment Share Follow Print See all 5 Comments 5 5 Comments reply Show 2 previous comments Abhishek Chavle commented Jul 22, 2021 reply Follow flag Open Hashing (Separate Chaining): In open hashing, keys are stored in linked lists attached to cells of a hash table. Closed Hashing (Open Addressing): In closed hashing, all keys are stored in the hash table itself without the use of linked lists. 0 0 replyShare surya_siddina commented Dec 21, 2024 reply Follow flag closed hashing also called linear probing. 1 1 replyShare panipuri commented Jul 25 i edited by panipuri Jul 25 reply Follow flag i agree, hashing terms are very confusing 😭😭😭$\underline{Open \ hasing} = seperate \ chaining \rightarrow$ It's called $\underline{open}$ because the data is allowed to leave the main array and grow out into the open space of your memory using linked lists also, $\underline{Open \ hashing }= \ \underline{closed \ addressing}$, i.e once you enter a slot you are closed there can't be mapped to any other slot $\underline{closed \ hasing} \rightarrow$ It's called $\underline{closed}$ because the data is strictly confined (closed in) to the fixed size of the hash table array. If there's a collision, you have to find an open address somewhere else inside the same array. also, $\underline{closed \ hasing} \rightarrow$ $\underline{Open \ addressing}$ 0 0 replyShare Please log in or register to add a comment.
Best answer 35 35 votes The answer is (B). $1$ will occupy location $0, 3$ will occupy location $6, 8$ hashed to location $0$ which is already occupied so, it will be hashed to one location next to it. i.e. to location $1$. Since $10$ also clashes, so it will be hashed to location $2$. Gate Keeda answered Jan 22, 2015 • edited Dec 31, 2017 by kenzou Gate Keeda comment Share Follow See all 10 Comments 10 10 Comments reply Show 7 previous comments Kuldeep Pal commented Jan 18, 2018 reply Follow flag Closed Hashing A closed hash table keeps the members of the set in the bucket table rather than using that table to store list headers. Consequently only one element is in any bucket. So, what happens if hash(x) = hash(y) when x and y are different? That is, what happens when we have a collision? We have a "rehash strategy". A "collision" occurs when we have i = hash(x) and the ith element of the table is already occupied (by something other than x). The rehash strategy chooses a sequence of alternative locations, hash-1(x), hash-2(x), hash-3(x), ..., within the table. We try each one of these locations in turn until we encounter an empty (unoccupied) location. If none exists, and we have exhausted the rehash strategy, we assume that the table is full and that we cannot insert x. A simple rehashing strategy, called "linear rehashing" is as follows: hash-i(x) = (hash(x) + i) mod B where there are B buckets in the hash table. Initially the table is empty, and each bucket holds a special value "empty", ie a value different from any value that we might insert into the table. 5 5 replyShare SHIVU12 commented Oct 15, 2019 reply Follow flag Closed hashing = Open Addressing 2 2 replyShare Kiyoshi commented Apr 29, 2021 reply Follow flag @ AspiROsa which is occupied. Next will be (3(x+1) + 4 mod)7? or (3x+4)mod7 +1 Ofcourse second one (3x+4)mod7 +1 or you can also say (3x+4+1)mod 7. because we are using linear probing. So, nearest slot after that will be checked first. 0 0 replyShare Please log in or register to add a comment.
5 5 votes B Rahul_kumar3 answered Oct 19, 2023 Rahul_kumar3 comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes https://youtu.be/1maxi3Yq-CU rohittulasyan answered Oct 11, 2018 rohittulasyan comment Share Follow 0 reply Please log in or register to add a comment.