CS & IT
Lab 22 · Systems and Data Lab: Data Structures in a Real Scenario (CS Tough)
🎯 Objective
Close the CS path at Tough level: move from knowing arrays, stacks and queues to defending a design choice with evidence.
🧩 Skills You Will Practice
- Arrays/lists
- stacks and queues in code
- Dictionaries for lookup
- Complexity reasoning (Big-O in plain words)
🧰 What You Need
- Python 3
- VS Code
- The Data Structures lesson
- A scenario worksheet in your notebook
📋 Step-by-Step Tasks
- Scenario 1 — Browser history: implement back/forward behaviour with two stacks in Python. Test visiting 5 pages, going back twice, forward once, and print the current page after each move.
- Scenario 2 — Print/task line: implement a queue using collections.deque for a helpdesk ticket line of 6 tickets. Process 3, add 2 urgent-at-the-back, and print the order — then state why a stack would be wrong here.
- Scenario 3 — Student lookup: store 8 students in a list and in a dictionary keyed by ID. Look up the same ID in both, explain in plain words why the dictionary stays fast as data grows (near-constant lookup) while the list scan grows linearly.
- Scenario 4 — Undo feature: add undo to a tiny text-list editor using a stack of actions. Perform 4 actions, undo 2, and show the state after each step.
- Measure honestly: use a simple loop count or timing on a large list (for example 100,000 items) comparing list search versus dictionary lookup, and record both results in your worksheet.
- Write the design defence: for each scenario, the structure chosen, the operation it makes fast, the operation it makes slow, and one real product that uses it.
✅ Expected Result / Deliverable
Working Python for 4 scenarios, a list-vs-dictionary measurement, and a written design defence per scenario — Tough CS thinking, with evidence.
⚠️ Common Mistakes
- Choosing a structure by familiarity instead of operations
- Claiming a timing result you did not actually run
- Forgetting the slow operation in the defence (every structure has one)
Safety, Ethics & Pro Tip
All data in this lab is invented by you. Performance claims in your portfolio must come from measurements you actually ran — never copy benchmark numbers as your own.