3 votes 3 votes Consider a hash table of $9$ slots implemented with linear probing. Suppose we insert $2$ elements in a sequence to a hash table with a simple uniform hashing assumption. What is the probability that we end up with $2$ consecutive slots of the hash table filled? Slot $i$ and $(i+1) \text{mod m}$ are defined to be consecutive slots. $1/2$ $1/3$ $1/4$ $2/3$ Algorithms goclasses2023-iiith-mock-1 goclasses algorithms hashing linear-probing 1-mark + – GO Classes asked Mar 26, 2023 • edited Mar 27, 2023 by Lakshman Bhaiya GO Classes 1.2k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
6 votes 6 votes First key can go to any slot. For the second key, we have $3$ options to map (left of first key, right of first key and to the same slot of first key). Hence probability $= 3/9 = 1/3.$ GO Classes answered Mar 28, 2023 GO Classes comment Share Follow See all 6 Comments See all 6 6 Comments reply KhushiRastogi commented May 3, 2023 reply Follow Share for two consecutive slots , we can have left right only how come the slot itself is counted in the probablity ? 1 votes 1 votes akashmaji945 commented Jan 8 reply Follow Share By similar idea: Can I say for 3 consecutive places upon 3 insertions, the probability should be: p = 1 * 3/9 * 4/9 = 4/27 0 votes 0 votes Prashant_Dubey commented Apr 24 reply Follow Share @KhushiRastogi consider open addressing and open chaining . 0 votes 0 votes abhirupb commented Apr 24 i edited by abhirupb Apr 24 reply Follow Share @Lakshman Bhaiya Solution is incorrect. 2nd one cannot be mapped to same slot. Question has asked for consecutive slotsFavourable cases: 9 ordered pairs like (slot 1 , slot 2), (slot1,slot 9), (slot 2 , slot 3)...etc. Every ordered pair can be filled up in 2 ways (key1,key2) or (key2, key1).. so total cases= 2*9=18Total cases= 81 (Each key has 9 options..Also can be thought as 9c2+ reflexive cases (slot1,slot1)..etc so, 72+9=81)so ans= 18/81=2/9 0 votes 0 votes yupitsaman commented 6 days ago reply Follow Share We have to consider the same slot because if the new element falls in the same slot, then we have to do probing and put it in the immediate next slot which leads to 2 consecutive slots filling. 2 votes 2 votes abhirupb commented 6 days ago reply Follow Share Shit you're correct. Completely missed that word linear probing in the question 🤦🏻 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes 9C2 ways to select any two slots and then there are 9 possible combinations of the consecutive slots (1,2),(2,3), (3,4),(4,5) ,(5,6),(6,7),(7,8),(8,9),(9,1). So shouldn’t it be ¼ ? Shubham_25 answered Apr 30, 2023 Shubham_25 comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes I think consecutive slots be like – (0,1), (1,2), (2,3), (3,4), (4,5),(5,6), ( 6,7), (7,8) ,(8,0) ==== 9 choices and the total number of options we have is 9C2 = 9 / 9C2 ==== ¼ ?? abhi_3_0_12 answered Apr 28, 2023 • edited May 2, 2023 by abhi_3_0_12 abhi_3_0_12 comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes First we select 2 places out of 9 places and then there are 9 possible combinations of the consecutive slots (0,1) ,(1,2) ,(2,3),(3,4),(4,5),(5,6),(6,7),(7,8),(8,0) so Answer is the ¼. ashutosh207 answered Aug 10, 2023 ashutosh207 comment Share Follow See all 0 reply Please log in or register to add a comment.