Pearson Edexcel 1CP2 GCSE Computer Science · Topic 1: Computational Thinking

Stretch tasks Decomposition and Abstraction

Task 1

Quiz Challenge

A quiz game against four computer players, then short and long written answers.

  1. Quiz Blitz12 questions against the clock
  2. Quick Fire4 short answers
  3. Big Think2 long answers

About 20 minutes

Task 2

This or That

Pixel the cat asks 8 questions. Each has two answers: pick the right one.

  • Two answers to every question
  • A fish treat for every right answer
  • Streaks win Pixel shades, then a party hat

About 4 minutes

Task 3

Memory Match

Flip the cards two at a time to match each term card to its meaning card.

  • 12 cards: each term has a meaning
  • One peek at every card
  • Combo points for pairs found in a row

6 pairs, about 4 minutes

Task 4

Sort It

Sort each statement into the right box, like the tick-box tables in the exam.

  • 11 cards to sort into 2 boxes
  • Drag a card, tap a box or press its number
  • Combo points for cards sorted in a row

11 cards, about 4 minutes

The games need JavaScript. Every question is below, with the answers at the end.

Read the lesson: Decomposition and Abstraction

Decomposition and Abstraction: the questions

Quiz Challenge, round 1: Quiz Blitz

  1. What is decomposition?

    • Writing code in Python
    • Making a file smaller
    • Breaking a large problem into smaller sub problems
    • Removing unnecessary detail
  2. What is abstraction?

    • Compressing data
    • Removing or hiding unnecessary detail
    • Breaking a problem into parts
    • Testing each part separately
  3. A shopping app is split into login, basket and payment. Which technique is this?

    • Compression
    • Iteration
    • Decomposition
    • Abstraction
  4. A sat nav keeps junctions and road lengths but ignores building colours. Which technique is this?

  5. Abstraction makes a file smaller in the same way as compression.

    • True
    • False
  6. Which TWO are benefits of decomposition?

    Tick 2.

    • The program always has fewer lines
    • The program can never have bugs
    • Detail is removed from the data
    • Several programmers can work on different parts at once
    • Each part can be tested in isolation
  7. Why does a chess program ignore the weight of the pieces?

    • It is too heavy to store
    • Weights are secret
    • Chess pieces weigh nothing
    • The rules of chess do not depend on it
  8. Writing total = calculate_fine(days_late) without knowing how the fine is worked out is an example of...

    • Abstraction
    • Decomposition
    • Validation
    • Compression
  9. Abstraction usually makes a model more accurate.

    • True
    • False
  10. Which detail should a school register keep?

    • Each pupil's eye colour
    • Each pupil's favourite subject
    • Each pupil's shoe size
    • Whether each pupil is present
  11. The total is wrong, but the input and sorting parts work. How has decomposition helped?

    • It hides the fault
    • The fault is narrowed down to the calculation part
    • It deletes the fault automatically
    • It makes the total correct
  12. What is a simplified representation of a real system, keeping only the relevant features, called?

Quiz Challenge, round 2: Quick Fire

  1. Explain why decomposition makes a large program easier to test. [2 marks]

  2. A company is writing an app that shows cyclists the safest route across a city. Explain how abstraction would be used when designing it. [3 marks]

  3. Explain the difference between decomposition and abstraction. [2 marks]

  4. Explain why a racing game leaves out real tyre chemistry and engine thermodynamics. [2 marks]

Quiz Challenge, round 3: Big Think

  1. A cinema chain wants a booking system that lets customers choose a film, pick seats and pay online. Explain how decomposition would be used to develop it, and the benefits this brings. [6 marks]

  2. A city council wants a computer model of traffic flow at a busy junction to test new traffic light timings. Discuss how abstraction would be used, and the benefits and drawbacks of using it. [6 marks]

This or That: tick the right answer

  1. Splitting a game into menus, levels and scoring is which technique?

    • Abstraction
    • Decomposition
  2. A Tube map ignores real distances between stations. Which technique?

    • Abstraction
    • Decomposition
  3. Does decomposition usually make code shorter?

    • Yes: that is its purpose
    • No: easier to test, not shorter
  4. Which should a sat nav keep?

    • Hedge heights
    • Speed limits
  5. A sub program called check_date is used in three different systems. Which benefit is this?

    • Reuse
    • Compression
  6. Abstraction removes detail that is...

    • Difficult to understand
    • Unnecessary for this problem
  7. Is a model built with abstraction exactly like the real thing?

    • Yes: nothing is lost
    • No: detail is left out on purpose
  8. An exam asks how abstraction is used in a scenario. What lifts the answer most?

    • Naming the details kept and removed
    • A longer general definition

Memory Match: match each term to its meaning

TermMeaning
A Decomposition1 A simplified version of a real system
B Abstraction2 Named code that hides how a task is done
C Sub problem3 Splitting a big problem into smaller parts
D Model4 Removing unnecessary detail
E Subprogram5 Precise steps that solve a problem
F Algorithm6 One small part of a larger problem

Sort It: tick one box in each row

Decomposition or abstraction? Sort each example.

StatementDecompositionAbstraction
Giving the search code and the fines code to different programmers
A chess program ignoring the wood grain of the pieces
A racing game skipping real tyre chemistry
Calling calculate_fine without knowing how it works
A register recording only present or absent
Breaking a game into menus, levels and scoring
Writing one sub program for each task
A sat nav ignoring the colour of buildings
Splitting a library system into issuing, returns and fines
A Tube map that ignores real distances
Testing the login part on its own
Answers

Round 1: Quiz Blitz

  1. Breaking a large problem into smaller sub problems Each sub problem can then be solved and tested on its own.
  2. Removing or hiding unnecessary detail What is left is only what is needed to solve the problem.
  3. Decomposition Splitting into parts is decomposition.
  4. abstraction Building colours never change which route is shortest.
  5. False Compression keeps the information in fewer bits. Abstraction throws unneeded detail away.
  6. Several programmers can work on different parts at once; Each part can be tested in isolation Decomposition also makes parts reusable and maintenance cheaper.
  7. The rules of chess do not depend on it Abstraction keeps only the piece type, its square and whose turn it is.
  8. Abstraction The sub program hides how, and shows only what.
  9. False It is less accurate on purpose, in exchange for being simpler and faster.
  10. Whether each pupil is present The register only has to record attendance.
  11. The fault is narrowed down to the calculation part Testing each part separately points straight at the faulty one.
  12. model A model is built using abstraction.

Round 2: Quick Fire

    • Each sub problem can be tested in isolation
    • So a fault can be narrowed down to one part
    Model answer

    Each sub problem is small enough to be tested in isolation. If the finished program is wrong, testing each part separately narrows the fault down to the one part that is failing.

    • Abstraction keeps only the detail needed to solve the problem
    • Kept: junctions, road lengths, cycle lanes, accident history
    • Removed: shop names, building colours
    Model answer

    Abstraction means keeping only the detail needed to solve the problem. The app would keep the junctions, road lengths, cycle lanes and accident history of each road, because they affect which route is safest. It would leave out shop names and building colours, because they never change the answer.

    • Decomposition splits a problem into smaller parts
    • Abstraction removes unnecessary detail
    Model answer

    Decomposition breaks a problem into smaller sub problems that can each be solved separately. Abstraction removes the detail that is not needed, so only what matters for solving the problem is left.

    • Full physics would need too much processing, so the game would be too slow
    • Players only need a believable feel, so the accuracy is unnecessary
    Model answer

    Simulating real tyre chemistry would need far more processing and memory, so the game would be too slow to run smoothly. Players only need a believable feel, so the extra accuracy is unnecessary detail.

Round 3: Big Think

    • Break the system into smaller sub problems
    • A sub problem such as the listings and showing times
    • A sub problem such as a seat map of available seats
    • A sub problem such as payment and confirmation
    • Different programmers can write parts at the same time
    • Each part can be tested separately, so faults are easier to find
    • Parts can be reused
    • Maintenance is easier, because a change touches only one part
    Model answer

    Decomposition would break the booking system into smaller sub problems: showing the listings and showing times, displaying a seat map of available seats, taking payment by card, and sending a confirmation with the tickets. Each sub problem is small enough to solve on its own, and different programmers could write them at the same time. Each part can be tested separately, so a fault in the total is quickly traced to the payment part. Parts can be reused, such as the payment module in the chain's snack shop app, and maintenance is easier, because changing how seats are shown means editing only that part.

    • Keep what affects flow: cars arriving, lanes, speeds, queues
    • Remove details such as car colour and drivers' names
    • Because the removed detail does not affect the result
    • It is simpler to design and program
    • It needs less memory and processing, so many timings can be tried quickly
    • But it is less accurate than the real world
    • Removing a detail that matters, such as pedestrians, gives wrong results
    • A conclusion, such as checking the model against real data
    Model answer

    Abstraction would keep only the details that affect traffic flow: the number of cars arriving per minute in each lane, their speeds, the queues and the light sequence. It would remove details such as the colour and make of each car and the drivers' names, because they do not affect how long the queues get. This makes the model simpler and quicker to design and program, and it needs less memory and processing, so it runs faster and many timings can be tried quickly. However, the model is less accurate than the real world, and if a detail that matters is removed, such as pedestrians crossing or buses stopping, its results could differ from reality. On balance, abstraction is worth it, provided the results are checked against real data from the junction.

This or That

  1. Decomposition Splitting into parts is decomposition. Abstraction leaves detail out.
  2. Abstraction A passenger only needs the stations and the connections between them.
  3. No: easier to test, not shorter Decomposition makes code easier to test, reuse and maintain. It rarely makes it shorter.
  4. Speed limits Speed limits change which route is fastest. Hedges do not.
  5. Reuse A decomposed part can be reused in every system that needs it.
  6. Unnecessary for this problem Abstraction is a judgement about which details matter for this particular problem.
  7. No: detail is left out on purpose A model trades accuracy for simplicity and speed.
  8. Naming the details kept and removed Application marks need nouns from the scenario, not a definition that fits anything.

Memory Match

  • A 3 Decomposition: Splitting a big problem into smaller parts
  • B 4 Abstraction: Removing unnecessary detail
  • C 6 Sub problem: One small part of a larger problem
  • D 1 Model: A simplified version of a real system
  • E 2 Subprogram: Named code that hides how a task is done
  • F 5 Algorithm: Precise steps that solve a problem

Sort It

  1. Decomposition Giving the search code and the fines code to different programmers Decomposition lets work be shared out.
  2. Abstraction A chess program ignoring the wood grain of the pieces The rules of chess do not depend on it.
  3. Abstraction A racing game skipping real tyre chemistry A believable feel matters more than accuracy.
  4. Abstraction Calling calculate_fine without knowing how it works The sub program hides its detail: abstraction.
  5. Abstraction A register recording only present or absent Only the needed detail is kept.
  6. Decomposition Breaking a game into menus, levels and scoring Splitting into parts is decomposition.
  7. Decomposition Writing one sub program for each task Each task in its own block is decomposition.
  8. Abstraction A sat nav ignoring the colour of buildings Leaving out detail is abstraction.
  9. Decomposition Splitting a library system into issuing, returns and fines Breaking the system into parts is decomposition.
  10. Abstraction A Tube map that ignores real distances Passengers only need the connections.
  11. Decomposition Testing the login part on its own Testing a part in isolation relies on decomposition.