Decomposing a problem into a hierarchy chart

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Decomposing a problem into a hierarchy chart

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Where does the main problem go in a hierarchy chart?
A In a box at the bottom
B In a single box at the top
2. Which is a sub-problem of the main problem 'Build a quiz app'?
A Show each question on the screen
B Build a quiz app
3. How is a hierarchy chart built?
A Split the problem into sub-problems, level by level
B Write every small task in one long row with no levels
4. When should you stop splitting a box into smaller boxes?
A When the task is small enough to solve on its own
B When the chart has exactly three levels
5. Which box is still too big to be a bottom-level task in a hierarchy chart for 'Make a school canteen ordering app'?
A Add up the price of the items in the cart
B Handle the whole ordering process

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Top box: Run a school canteen app AThe sub-problem 'Write the code for everything' is still too big and is not a small task. It should be split into smaller sub-problems like Ask questions, Check answers and Show score.
2Run a school canteen app -> Take orders, Handle payments, Show menu BSub-problems placed as boxes below the main problem, each one a smaller part of it
3Keep splitting a sub-problem until each box is a small task that can be solved on its own CThe top box lists several tasks instead of one main problem. 'Make a quiz game' should be alone at the top, with the other tasks as sub-problem boxes below it.
4A small sub-problem box on the chart can later become a function in the program DHandle payments -> Enter card details, Check funds, Print receipt
5Top box: Make a quiz game, Show score, Ask questions, Save high scores EThe top-level problem box that states the one main problem to be decomposed
6Make a quiz game -> Write the code for everything FBox: Check funds -> def check_funds(balance, price):

Definitions

hierarchy chart

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
Level _: Make a quiz app Level 2: Ask questions Level 2: Show score
2.
Level 1: Make a quiz app Level 2: Ask questions Level _: Pick one question
3.
____________: Make a quiz app Sub-problem: Ask questions Sub-problem: Show score
4.
Box: Show score ________ showScore() PRINT score
5.
IF task is too big THEN split it again ____ stop and solve it

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A Main: Organise a school disco
B Sub: Organise a school disco
C Sub: Sell tickets
D Sub: Set up the hall
Question 2
A Main: Build a quiz app
B Sub: Make the questions
C Sub: Make the questions
D Sub: Show the score
Question 3
A Main: Make a weather app
B Sub: Get weather data
C Task: Build the whole app
D Sub: Display the forecast
Question 4
A Main: Run a canteen app
B Sub: Order -> order()
C Sub: Pay -> pay()
D Sub: Pickup -> pay()
Question 5
A Main: Create a school website
B Sub: Design the pages
C Sub: Write the content
D Sub: Bake a chocolate cake

Answer Key

Decomposing a problem into a hierarchy chart
Section A: Quick Questions
Q1
B — In a single box at the top
Q2
A — Show each question on the screen
Q3
A — Split the problem into sub-problems, level by level
Q4
A — When the task is small enough to solve on its own
Q5
B — Handle the whole ordering process
Section B: Match the Pairs
Q1
Top box: Run a school canteen app → The top-level problem box that states the one main problem to be decomposed
Q2
Run a school canteen app -> Take orders, Handle payments, Show menu → Sub-problems placed as boxes below the main problem, each one a smaller part of it
Q3
Keep splitting a sub-problem until each box is a small task that can be solved on its own → Handle payments -> Enter card details, Check funds, Print receipt
Q4
A small sub-problem box on the chart can later become a function in the program → Box: Check funds -> def check_funds(balance, price):
Q5
Top box: Make a quiz game, Show score, Ask questions, Save high scores → The top box lists several tasks instead of one main problem. 'Make a quiz game' should be alone at the top, with the other tasks as sub-problem boxes below it.
Q6
Make a quiz game -> Write the code for everything → The sub-problem 'Write the code for everything' is still too big and is not a small task. It should be split into smaller sub-problems like Ask questions, Check answers and Show score.
Section C: Definitions
Q1
hierarchy chart — A diagram that splits one main problem into smaller sub-problems in boxes, level by level, until each box is a small task that can be solved on its own.
Section D: Fill in the Blanks
Q1
Level 1: Make a quiz app Level 2: Ask questions Level 2: Show score
Q2
Level 1: Make a quiz app Level 2: Ask questions Level 3: Pick one question
Q3
Main problem: Make a quiz app Sub-problem: Ask questions Sub-problem: Show score
Q4
Box: Show score FUNCTION showScore() PRINT score
Q5
IF task is too big THEN split it again ELSE stop and solve it
Section E: Spot the Error
Q1
B — A sub-problem must be a smaller part of the main problem. This box just repeats the main problem, so it does not split anything. It should be a part such as 'Choose the music'.
Q2
C — Each sub-problem box must be a different part of the main problem. This box repeats 'Make the questions' from line 2, so the marking part is missing. It should be 'Sub: Mark the answers'.
Q3
C — A Task box is where we stop splitting, so it must be small enough to solve on its own. 'Build the whole app' is the original big problem. It should be a small task such as 'Read the city name'.
Q4
D — Each sub-problem later becomes its own function, so it needs its own matching name. pay() is already used by the 'Pay' box. The Pickup box should use pickup().
Q5
D — Every sub-problem must help solve the main problem. Baking a cake has nothing to do with creating a website. It should be a related part such as 'Test the links'.