Interview: How Bloom Filters Work?
Bloom Filters Explained With a Username Check!?
An app with 500 million users can’t afford a database query every time someone types a username. A Bloom filter handles most of those checks in memory. It’s a long row of bits, all starting at 0, plus a few hash functions that turn any text into a number. When “John” signs up, three hash functions return positions like 4, 19 and 42, and those bits flip to 1. The word “John” itself is never stored in the filter.
To check a new username, hash it the same way. If any of its bits is still 0, that name was never added, so it’s definitely available. If all its bits are 1, the name might be taken, since other usernames could have flipped those same bits. That’s a false positive, and only then does the app ask the database.
?Subscribe if you want more data structures explained with real examples.
#BloomFilter #SystemDesign #DataStructures #HashFunctions #BackendEngineering #SoftwareEngineering #Programming #Scalability #DatabaseOptimization #ComputerScience #CodingInterview #TechExplained #KodeKloud
KodeKloud
...