REVISION AND PRACTICE

Revision studio and mixed practice

1 min read

Predict each key and value before moving the walkthrough. Change record order, representation or distance rule, then explain what changes and what remains the same.

REAL COURSE DATA · KEYS, COUNTS AND CONNECTIONS

Four birthday dictionary representations

Follow the dictionary as its keys and values change. Predict each lookup or update before revealing the next step.

Ready

CURRENT RECORD / VALUE

Ready to begin

No records have been processed. Start with Next step.

What we remember

Processed
0

Predict the next key, whether it already exists, and the value that will be stored.

Try it yourself

D={} then D["x"]=4 then D["x"]=6. What is D?

Show explained answer

{"x":6}. One key remains; its value is replaced.

Try it yourself

D={"x":0}. Is x present?

Show explained answer

Yes. isKey(D,"x") is True.

Try it yourself

A birthday count map has values 2,1,1. How many observed birthday keys and student records?

Show explained answer

3 keys and 4 records.

Try it yourself

Does duplicates[d]=True on a third occurrence add a second date entry?

Show explained answer

No. The existing key is assigned True again.

Try it yourself

For four students on one date, how many unordered matching pairs?

Show explained answer

4×3/2=6.

Try it yourself

What does keys({7:True,21:True}) represent?

Show explained answer

The two ID keys, in an unspecified order.

Try it yourself

A word length appears five times. What value should its frequency store?

Show explained answer

5, counting every occurrence.

Try it yourself

A key is absent. Can you safely add D[k]+1?

Show explained answer

No. First initialize it or use a first-occurrence branch.

Try it yourself

How many unordered pairs among six distinct customers?

Show explained answer

15.

Try it yourself

Does close(1,5) and close(5,6) prove close(1,6)?

Show explained answer

No. Distances 10,10,16 give a counterexample at threshold10.

Try it yourself

What is Abhinav–Akshaya Manhattan distance?

Show explained answer

7, from absolute gaps 0,5,2,0,0.

Try it yourself

What does an empty dictionary average return?

Show explained answer

No defined average; avoid division by zero.

Try it yourself

How many Food rows are on Ahmed’s Bill25?

Show explained answer

0. It has Electronics, Accessories and Stationery rows.

Try it yourself

Which bills contribute Ahmed’s18 Food rows?

Show explained answer

18,20,29 contribute8,7,3.

Try it yourself

What are complete-dataset Food shop totals?

Show explained answer

SV Stores73, Big Bazaar15, Sun General9; grand total97.

Try it yourself

Why is a full scan through keys(D) not constant time?

Show explained answer

It visits one entry per key, so its work grows with the number of keys.

Try it yourself

For noun positions [1,3,8,14,19] and pronoun17, what is matched?

Show explained answer

14, the largest noun position below17.

Try it yourself

Why does the noun matcher need sorted noun positions?

Show explained answer

Its early exit assumes all later noun positions are larger.

Try it yourself

What is matchD[0] for the supplied paragraph?

Show explained answer

−1: no noun precedes the first pronoun.

Try it yourself

Does a customer count prove a personal or family characteristic?

Show explained answer

No. It summarizes observed purchase rows under a chosen grouping and measure.

YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑