Neural Sync Active
Computational Thinking · Week 6 — Tables & dictionaries
Registry Synced
Computational Thinking · Week 6 — Tables & dictionaries
1034 words
5 min read
2026-08-16
Reading compass
Now · Week map
Week 6 — tables & dictionaries
Quiz 2 scope: Weeks 1–8 per IITM May 2026 foundation courses. Source baseline: IITM BS admissions important-dates calendar · May 2026 cycle. Times on assessments are operational conventions — verify hall ticket.
Week map
Table dimensions → cell access → dict as column map → frequency count
Classify → Represent → Execute → Trap-check
- Recognize: Ask: How is a table cell addressed?
- Procedure: Identify row and column from labels. Value at (2,3) is row 2 column 3 per course convention—verify problem statement.
- Variations / traps: Watch for: Row/column index swapped.
Formula chain (compressed)
table rows×cols → dict key→value → frequency count pattern.
- Table —
row i, column j— 2D grid access - Dictionary —
key ↦ value— lookup by label - Frequency —
count[key] += 1— tally occurrences - Row scan —
for j in cols: T[i][j]— fix row, sweep columns - Missing key —
default 0 before +=— init or get
Open interactive formula desk · Week 6 tab.
Deep study
Computational Thinking · Week 6 — Tables and dictionaries
Deep study for Quiz 2 week 6. Tables organize records in rows; dictionaries map keys to values for fast lookup and counting.
Week map
Row/column table → record as dict → key-value lookup → frequency tally → table vs dict tradeoff.
Table notation
- Row → one record → e.g. student name + score + section.
- Column → one field across rows → all scores, all names.
- Cell → intersection of row and column → single value.
- Header → column labels → keys when converting to dict.
Mini-table:
| Name | Score |
|---|---|
| Ada | 88 |
| Ben | 92 |
Row 1 cell (Ada, Score) = 88. Column Score = {88, 92}.
List of records (table as data)
texttable ← [ {Name: Ada, Score: 88}, {Name: Ben, Score: 92} ]
Access row 0 field Score → 88.
Dictionary notation
- Key → unique identifier → string, number, tuple.
- Value → data stored → any type.
- Lookup → given key, retrieve value in O(1) average time (conceptually constant).
map[key] ← value→ insert or update.
Mini-example: frequency of letters in "aba":
textfreq ← empty map for each character c in string: if c in freq: freq[c] ← freq[c] + 1 else: freq[c] ← 1
Result: {a: 2, b: 1}.
Pattern families
Easy — Read table cell
From small grid or list-of-dicts, fetch one value. Identify row vs column.
Medium — Build dict from table
Convert parallel columns to records. Count occurrences. Lookup by key; handle missing key.
Hard — Aggregate with dict
Group rows by category key. Sum or average values per group. Merge two tables on shared key.
Worked mini-examples
Example 1 — Row access.
Three rows, columns (ID, Qty): row 2 ID cell = value in column ID at index 1 (0-based).
Example 2 — Dict lookup.
phone["Ana"] = "555-0100". Lookup "Ana" → number. Lookup missing key → error unless default policy stated.Example 3 — Frequency.
Items [red, blue, red, green]: freq red=2, blue=1, green=1.
Example 4 — Dict of lists (column store).
textdata.Name ← [Ada, Ben] data.Score ← [88, 92]
Column Name row index 1 → Ben.
Example 5 — Update vs insert.
If key exists, overwrite value; dict size unchanged. New key increases size by 1.
Traps
- Row index vs ID column value — row 3 ≠ ID 3 unless stated.
- Missing key in dict — define behavior (0, null, error).
- Counting rows vs counting distinct keys.
- Assuming table sorted unless specified.
- Confusing list index with dict key.
Diagnostic (try yourself)
-
In a 4-row table with columns A and B, what does cell (row 3, B) mean?
-
Map {x: 10, y: 20}. What is value at x? What happens at z without default?
-
Count how many times "the" appears in word list [the, cat, the, sat].
-
Represent the mini-table above as one dict mapping Name → Score.
-
When is dict better than scanning entire table for each lookup?
ChatGPT prep archive
Archived import for extra depth — complements the notes above, not official IITM material.
Core concepts
- Table: rows × columns; cell (r,c) identifies one value.
- Dictionary: key maps to value; fast lookup by key.
- Frequency: count repeats per key in data stream.
- Row vs column: row is horizontal record; column is field across records.
Notation & vocabulary
| Structure | Access |
|---|---|
| table | row r, column c |
| dict | key k → value |
| frequency dict | item → count |
Pattern families
Easy — Read table cell
Identify row and column from labels. Value at (2,3) is row 2 column 3 per course convention—verify problem statement.
Medium — Build frequency dict
Loop items; increment dict[item]. Missing key means zero before increment.
Hard — Table + dict combine
Use dict to store column totals keyed by header. Double loop rows then columns accumulating.
Drill these on the pattern atlas — filter to week 6.
Traps
- Row/column index swapped.
- 1-based vs 0-based in problem statement.
- Dict key typo creates duplicate buckets.
- Frequency before vs after normalization.
Retrieval prompts
- How is a table cell addressed?
- Dict vs table when to use?
- Steps to build frequency map?
Practice loop
- Read Deep study (if present) or core concepts once.
- Recite the formula chain without looking.
- Open one easy pattern on the interactive atlas for week 6.
- Attempt without solutions; mark studied after an honest try.
- Say one trap aloud before closing the tab.