1 1 vote Suppose you have a hash table that can hold $100$ elements. It currently stores $30$ elements (in one of $30$ possible different locations in the hash table). The probability that your next two inserts will cause at least one collision is ( by assuming a totally random hash function) __________ Programming in C tbb-ds-2 numerical-answers probability hashing data-structures + – Bikram 3.0k views answer comment Share Follow Print See 1 comment 1 1 comment reply David commented Dec 1, 2016 reply Follow flag We need to round off till 2 decimals .. 0.5170 is taken as wrong answer :( 1 1 replyShare Please log in or register to add a comment.
Best answer 8 8 votes Second Method to solve this problem :- 3 cases are possible when we insert 2 elements in hash table Case 1- Collision on First insertion and Not Collision on Second Insertion P(case-1) = (30/100)* (69/100) = 0.207 Case 2- Not Collision on First insertion and Collision on Second Insertion P(case-2) = (70/100)* (31/100) =0.217 Case 3- Collision on both First insertion and Second Insertion P(case-3) = (30/100)*(31/100) = 0.093 Finally, Required Probability = P(Case-1) or P(Case-2) or P(Case-3) =0.207 + 0.217 + 0.093 = 0.517 Note - This method is only efficient when number of insertion is less. ShiveshRoy answered Feb 4, 2017 • selected Aug 8, 2017 by Bikram ShiveshRoy comment Share Follow See 1 comment 1 1 comment reply anjali007 commented Dec 30, 2018 reply Follow flag @ShiveshRoy @Bikram shouldnt it be 30/100 and 30/100 for collision on first insertion means that we are hasihng to one of the 30 possible options and 2nd time collision also means that we are hashing again to one of these 30 slots ... pls explain .. 0 0 replyShare Please log in or register to add a comment.
5 5 votes 1-p0 = 1- (70/100 * 69/100 ) Bikram answered Nov 26, 2016 Bikram comment Share Follow See all 9 Comments 9 9 Comments reply Show 6 previous comments Bikram commented Feb 3, 2017 reply Follow flag @shivesh very good solution, if possible write this as an answer . Good solve. 1 1 replyShare ShiveshRoy commented Feb 4, 2017 reply Follow flag Sure @Bikram Sir.. 0 0 replyShare pCS commented Aug 8, 2017 reply Follow flag @ShiveshRoy sir please clarify my doubt in your solution. If chaining is used for collision resolving (instead of probing) then won't the cases give different answer? ex case1 : (30/100)*(70/100) because there will still be 70 free slots after the 1st collision. Likewise for the other cases. 0 0 replyShare Please log in or register to add a comment.