Workstation topics · Data structures in plain words
Lookups and trees: find it fast, and things inside things
🏠The everyday picture
To call your aunt, you don't scroll through every number in your phone: you type her name and the number comes up. That's a lookup. And your family's history is a tree: grandparents at the top, their children below, and grandchildren below them. Programs use both shapes constantly.
📘What it really is
A lookup (called a dictionary in Python, an object or Map in JavaScript, a hash map in many other languages) stores key → value pairs:
- You find a value by its key, quickly, without checking every item.
- Each key appears only once. Saving a new value under the same key replaces the old one.
- Used for: a contact list (name → number), stock levels (item → quantity), settings (language → "Hindi").
A tree keeps things inside other things, with one root at the top:
- Each item can have children below it. An item with no children is a leaf.
- Used for: folders on a computer (a folder inside a folder), a company's staff chart, the parts of a web page (the page holds sections, sections hold paragraphs), and categories in a shop (Clothes, then Sarees, then Silk).
📝A worked example
Sharma Textiles' stock as a lookup:
stock = { "Silk saree": 12, "Cotton saree": 40, "Dupatta": 25 }
stock["Dupatta"] → 25 (found by its name, straight away)
stock["Silk saree"] = 10 → the old 12 is replaced by 10
And its shop categories as a tree:
Shop
├── Sarees
│ ├── Silk
│ └── Cotton
└── Dress material
└── Dupattas
"Shop" is the root. "Silk", "Cotton" and "Dupattas" are leaves: they have nothing below them.
🖱️Try it
Draw your own family, or your school or office, as a tree. Who is the root? Which are the leaves? Then write five
contacts from your phone as a lookup, name → number. What happens if two contacts have exactly the same name?
✅Quick check
In a lookup, you save "Tea" → 30, then later "Tea" → 18. How many entries for Tea are there?
Show the answer
One. A key appears only once, so the new value 18 replaces 30.
Your computer's folders: Documents holds Shop, and Shop holds Bills. Which is the leaf, if Bills has nothing inside?
Show the answer
Bills. A leaf is an item with nothing below it.
🧩Check yourself
Tap an answer to see why every option is right or wrong. There's no score and nothing is saved, so try as often as you like.
