Skip to main content

Command Palette

Search for a command to run...

How Dictionary Changed Programming

Updated
•3 min read•View as Markdown

Chapter 1 - The World Before Dictionaryo

Imagine you're a librarian in a huge library.
Someone asks,
"Can you bring me the book Python Basics?"
You don't know where it is.
So you check the first shelf...
Not there.
Second shelf...
Not there.
Third shelf...
After searching hundreds of shelves, you finally find it.
Computers had the same problem.
Before dictionaries, programs searched data one item at a time.
Finding one value inside millions could take a long time.
People asked,
"Can we find information instantly instead of searching everything?"

Chapter 2 - The Hero Arrives

Computer scientist invented the Dictionary. Instead of searching every item...
the program creates a special relationship.

Student= {
"Name":"Rahul";
"Roll":20 ;
"City":"Ranchi"
}

Now the computer dosen't search everything.
it simply asks,
"Where is the value for the key 'Roll'?"
Immediately...
20 appears.
Almost like magic.
The old problem was solved.
Finding data became incredibly fast.
Everyone celebrated.

Chapter 3 - But Every Hero Creates New Villans

Soon developers notice something strange.
The dictionary solved one problem...
but created many new ones.

Problem 1 - Memory

Imagine keeping a notebook where every word has its own page. it becomes very fast to find information...
but the notebook become huge.
A dictionary also uses extra memory.
Fast speed has a price.

Problem 2 - Billions of Words

Now imagine Google.
it dosen't store hundreds of words.
it store billions
Can one dictionary hold everything?
How can we organize such enormous data?
A new challenge appeared.

Problem 3 - Counting Things

A teacher asks,
"How many times did each animal appear?"
Cat
Dog
Cat
Bird
Dog
Without dictionary, counting is difficuilt.
With a dictionary:
Cat - 2
Dog - 2
Bird - 1
Amazing!
But What if the lists contains 10 billion words?
Now memory become another challenge.

Problem 4 - Caching

Suppose calculating something takes five minutes.
Why calculate it again?
The computer remembers the answer inside a dictionary.
This is called cache.
Problem solved.
But another question appears...
How long should we keep old data?
if we never delete it,
memory keeps growing forever.

Problem 5- Hash Collisions

Think of apartment numbers.
Two people accidently receive the same apartment number.
Now both reach the same door.
Confusion!
This also happen in dictionaries.
Different keys sometimes produce the same hash.
This is called collision.

Computer scientist invented collision handling techniques.
Problem solved...
again.

Real World Example Of Dictionary

  • Student Record
  • Employee information
  • Contact details