REVISION AND PRACTICE

Week 5 revision and mixed practice

1 min read

Choose a lab to revisit any idea, then try the questions without opening the answer. Explain the list’s element type, its ordering, whether repeats matter, and what each variable means.

REAL COURSE DATA · BUILD AND UNPACK LISTS

Build May and Chennai ID lists

Follow one occurrence at a time. Choose another input to test empty lists, repeated IDs and different parameters.

Ready

CURRENT RECORD / VALUE

Ready to begin

No records have been processed. Start with Next step.

What we remember

Processed
0

Predict the next change, then step through the list. The original course records remain unchanged.

Try it yourself

What is the outer length of [[3,53],[24,72],[12,64]]?

Show explained answer

3. The outer list has three pair elements, each with two components.

Try it yourself

Evaluate [1,13] ++ [] ++ [2,17,1].

Show explained answer

[1,13,2,17,1]. Empty concatenation adds nothing; repeated values stay.

Try it yourself

What is first(rest([3,42,53]))?

Show explained answer

42. rest gives [42,53], whose first element is 42.

Try it yourself

What is last(init([3,42,53]))?

Show explained answer

42. init gives [3,42], whose last element is 42.

Try it yourself

Does first(rest([3])) return 3?

Show explained answer

No. rest([3]) is [], so first of that empty list is undefined.

Try it yourself

For L = [3,3,25], reconstruct L from first and rest.

Show explained answer

[first(L)] ++ rest(L) = [3] ++ [3,25] = [3,3,25].

Try it yourself

What does a raw nested intersection of [3,3] and [3,3] append?

Show explained answer

Four occurrences of 3, one per matching pair of positions. Add a uniqueness rule if set-style output is intended.

Try it yourself

Why is the third-highest distinct Physics cutoff 88 even though several students score 92?

Show explained answer

Repeated 92 scores share one mark level. The distinct levels are 92,91,88.

Try it yourself

What are the all-three subject topper IDs?

Show explained answer

[11]. Maths ∩ Physics is [11,23]; intersecting Chemistry removes 23.

Try it yourself

Can the fourth subject Biology be read from the supplied scores?

Show explained answer

No. It is a hypothetical extension in the lecture. The actual dataset contains Maths, Physics and Chemistry.

Try it yourself

How many neighbour comparisons does a successful sortedness check need for 30 elements?

Show explained answer

29 adjacent comparisons, apart from helper-function implementation costs.

Try it yourself

Is dismal immediately followed by the noun building?

Show explained answer

No. Yellow is between them. The immediate adjective–noun pair is yellow–building.

Try it yourself

How many adjacent vowel pairs occur in aaaa?

Show explained answer

Three: positions 1–2, 2–3 and 3–4. Overlap is allowed.

Try it yourself

Does matching the endpoints of abca prove it a palindrome?

Show explained answer

No. Removing the matching outer a characters leaves b and c, which differ.

Try it yourself

What update is needed when a new maximum is strictly larger?

Show explained answer

Replace both the maximum value and its owner list; begin the new owner list with just this ID.

Try it yourself

Are [ID,Physics] and [ID1,ID2] interchangeable pair schemas?

Show explained answer

No. They have the same list length but different meanings. Algorithms must know which fields each position contains.

Try it yourself

Does “within ten” form a transitive relation?

Show explained answer

Not generally. 74 is within ten of 81 and 81 within ten of 85, but 74 and 85 are eleven apart.

Try it yourself

How many Bill 1 food triples are there, and what do they count?

Show explained answer

Five, counting food item rows. They do not count units, quantities or distinct categories.

Try it yourself

What assumption is needed to use the endpoints for minimum and maximum?

Show explained answer

The list must be non-empty and ordered non-decreasingly by that numeric property.

Try it yourself

Why is the lecture’s mean position difference not a population conclusion?

Show explained answer

The ten students were selected for low Maths marks and tied-position conventions affect the measure. It is a descriptive calculation for that setup.

YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑