Problem on Probability -- Hash Table & Collisions

Click For Summary

Discussion Overview

The discussion revolves around a probability problem related to hash tables and collision resolution using external chaining. Participants analyze the probabilities associated with the state of a hash table after a series of insertions, specifically focusing on the likelihood of certain buckets being empty, the occurrence of collisions, and the conditions under which these events happen.

Discussion Character

  • Homework-related
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • Post 1 presents a homework statement with specific probability calculations for a hash table scenario, including the probability that bucket number 1 is empty after K insertions, the probability of no collisions, and the probability of the first collision occurring at the K-th insertion.
  • Post 2 questions the derivation of the last factor in the probability for the first collision at the K-th insertion, suggesting that the rest of the calculations appear correct.
  • Post 3 reiterates the question about the last factor and provides a breakdown of the probability of no collisions occurring in the first K-1 insertions, leading to a proposed formula for the first collision probability.
  • Post 4 challenges the reasoning behind the probability of the K-th element colliding, arguing against the assumption that it would be ##\frac{1}{k-1}## based on the number of filled slots.
  • Post 5 continues the challenge from Post 4, suggesting an alternative probability expression for the collision scenario.
  • Post 6 and Post 7 acknowledge the correction regarding the numerator in the probability expression, indicating a consensus on the correct formulation but still reflecting uncertainty in the overall reasoning.

Areas of Agreement / Disagreement

Participants express disagreement regarding the probability calculations, particularly concerning the derivation of the last factor in the collision probability. There is no consensus on the correct approach to calculating the probability of the first collision occurring at the K-th insertion.

Contextual Notes

Participants rely on specific assumptions about the behavior of hash functions and the distribution of keys, which may not be universally applicable. The discussion contains unresolved mathematical steps and differing interpretations of probability in the context of hash tables.

22990atinesh
Messages
143
Reaction score
1

Homework Statement


Consider a hash table with ##n## buckets, where external (overflow) chaining is used to resolve collisions. The hash function is such that the probability that a key value is hashed to a particular bucket is ##\frac{1}{n}##. The hash table is initially empty and ##K## distinct values are inserted in the table

(a) What is the probability that bucket number 1 is empty after the the ##K^{th}## insertion ?
(b) What is the probability that no collision has occurred in any of the ##K## insertions ?
(c) What is the probability that the first collision occurs at the ##K^{th}## insertions ?

Homework Equations

The Attempt at a Solution


Probability that a key value is hashed to the first bucket = ##\frac{1}{n}##
Probability that a key value is doesn't hashed to the first bucket = ##1 - \frac{1}{n}## = ##\frac{n-1}{n}##

(a) Probability that bucket number 1 is empty after the the ##K^{th}## insertion = ##(\frac{n-1}{n})^k##
(b) Probability that no collision has occurred in any of the ##K## insertions = ##1 \times \frac{1}{n-1} \times \frac{1}{n-2} \times ... \times \frac{1}{n-(k-1)}##
(c) Probability that the first collision occurs at the ##K^{th}## insertions = ##1 \times \frac{1}{n-1} \times \frac{1}{n-2} \times ... \times \frac{1}{n-(k-2)} \times \frac{1}{k-1}##

are my above ans correct or I've done some mistake. Please share
 
Physics news on Phys.org
Where does the last factor at (c) come from?
Everything else looks right.
 
mfb said:
Where does the last factor at (c) come from?
Everything else looks right.

Probability that no collision has occurred in any of the ##K-1## insertions P(K-1)= ##1 \times \frac{1}{n-1} \times \frac{1}{n-2} \times ... \times \frac{1}{n-(k-2)}##
Probability that the first collision occurs at the ##K^{th}## insertions = ## P(K-1) \times## Probability of collision of ##K^{th}## element
As K-1 slots are filled, first collision will occur if ##K^{th}## element will get into these slot, It'll do it with probability = ##\frac{1}{k-1}##
Hence
Probability that the first collision occurs at the ##K^{th}## insertions = ##1 \times \frac{1}{n-1} \times \frac{1}{n-2} \times ... \times \frac{1}{n-(k-2)} \times \frac{1}{k-1}##
 
22990atinesh said:
As K-1 slots are filled, first collision will occur if ##K^{th}## element will get into these slot, It'll do it with probability = ##\frac{1}{k-1}##
No it does not.
If 2 out of 100 slots are filled, then the next element won't go to a filled slot with a probability of 1/(3-1)=1/2.
 
mfb said:
No it does not.
If 2 out of 100 slots are filled, then the next element won't go to a filled slot with a probability of 1/(3-1)=1/2.

Would it be ##\frac{k}{n}## in place of ##\frac{1}{k-1}## in (c)
 
Nearly. The numerator should be k-1.
 
  • Like
Likes   Reactions: 22990atinesh
mfb said:
Nearly. The numerator should be k-1.
Oops little mistake, you are right. ##\frac{k-1}{n}## is right.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
796
  • · Replies 1 ·
Replies
1
Views
500
  • · Replies 1 ·
Replies
1
Views
464
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 13 ·
Replies
13
Views
4K
Replies
2
Views
2K