Inverted Index Visualizer
About This MicroSim
This MicroSim demonstrates how inverted indexes enable fast search by mapping terms to the documents containing them.
Iframe Embed Code
1 2 | |
Description
What is an Inverted Index?
Instead of storing "Document → Words", an inverted index stores "Word → Documents":
| Traditional | Inverted Index |
|---|---|
| Doc1: [pendulum, physics, simulation] | pendulum: [Doc1, Doc3] |
| Doc2: [wave, visualization] | physics: [Doc1, Doc2] |
| Doc3: [pendulum, motion] | wave: [Doc2] |
How to Use
- View documents on the left panel
- Click terms in the index to highlight which documents contain them
- Enter a query and click "Trace Query" to see the lookup process
- Add more documents to see the index grow
- Click "Build Index" to watch index construction
Why Inverted Indexes?
| Without Index | With Inverted Index |
|---|---|
| Read every document | Look up term directly |
| O(n) time complexity | O(1) lookup time |
| Slow for large collections | Fast for any size |
| Scales poorly | Scales excellently |
Learning Objectives
After using this MicroSim, students will be able to:
- Explain how inverted indexes map terms to documents
- Trace query lookups through the inverted index
- Compare index-based search vs linear scan
Lesson Plan
Introduction (5 minutes)
- Analogy: Back-of-book index vs reading every page
- Why search engines can't read every document for every query
Index Construction (10 minutes)
- Start with 3 documents
- Click "Build Index" to watch construction
- Add documents and observe index growth
- Discuss: Why are some posting lists longer?
Query Tracing (10 minutes)
- Enter query "pendulum wave"
- Click "Trace Query"
- Observe how terms are looked up
- See intersection of posting lists (AND search)
Discussion Questions (5 minutes)
- What happens to the index when you add a new document?
- Why is updating an inverted index potentially expensive?
- How might you handle synonyms in an inverted index?