Pattern recognition in a problem

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

Pattern recognition in a problem

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A school canteen app needs to enter data for 5 different class orders. Each order uses the same steps: enter name, enter item, enter quantity. What is this an example of?
A Pattern recognition: the same data entry steps repeat
B Validation: checking that the data is reasonable
2. Which statement best describes pattern recognition in a problem?
A Spotting similarities in sub-problems so one solution can be reused
B Splitting a problem into smaller parts without comparing them
3. A library system stores students, books and loans. Each record has an ID, a name or title, and a date. What pattern can you spot?
A The records are all the same, so only one table is needed
B The records have similar structures, so one design can be reused
4. Why is recognising a pattern useful when solving a data-driven problem?
A You can write one solution and reuse it for similar tasks
B You must write a separate solution for every sub-problem
5. A student must enter marks for Maths, English and Science. Each subject uses the same steps: input the mark, check it is 0 to 100, store it. What should the student do?
A Write three completely different sets of steps
B Design one set of steps and reuse it for each subject

Match the Pairs

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

Left columnRight column
1for i from 1 to 30: input name AA similar record structure: many records share the same fields, so one design can be reused
2record Student: name, year, house Bwhile more items: input item
3Reusing one solution for similar tasks: the same check is needed on several inputs, so write it once as a function CThe repeated input steps were written out one by one, so the pattern was missed. A loop should repeat one input step.
4Spotting a repeated data entry step: the same input and store steps happen for each item, so one loop covers them Ddefine checkMark(mark)
5input name1 input name2 input name3 input name4 EThe similar record structure was not recognised. One table design with the same fields can be reused for every class.
6Make a different table design for every class, even though each class list has the same fields FA repeated data entry step: the same input action happens for every student, so one loop can be reused

Definitions

pattern recognition

Fill in the Blanks

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

1.
___ i from 1 to 30 input mark total ← total + mark
2.
______ calcTotal(price, qty) return price * qty
3.
define calcTotal(price, qty) return price * qty cost ← _________(25, 2)
4.
_____ count < 10 input name count ← count + 1
5.
for i from 1 to 5 input mark total ← total _ mark

Spot the Error

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

Question 1
A total <- 0
B for i from 1 3
C input mark
D total <- total + mark
E end for
Question 2
A define addGST(price)
B gst <- price * 0.1
C total <- price + gst
D return gst
E end define
Question 3
A record Person
B name: integer
C email: string
D end record
E student: Person
F teacher: Person
Question 4
A define cube(n)
B return n * n * n
C end define
D print cube(3, 5)
E print cube(5)
Question 5
A for i from 1 to 5
B input name
C print age
D save name, age
E end for

Answer Key

Pattern recognition in a problem
Section A: Quick Questions
Q1
A — Pattern recognition: the same data entry steps repeat
Q2
A — Spotting similarities in sub-problems so one solution can be reused
Q3
B — The records have similar structures, so one design can be reused
Q4
A — You can write one solution and reuse it for similar tasks
Q5
B — Design one set of steps and reuse it for each subject
Section B: Match the Pairs
Q1
for i from 1 to 30: input name → A repeated data entry step: the same input action happens for every student, so one loop can be reused
Q2
record Student: name, year, house → A similar record structure: many records share the same fields, so one design can be reused
Q3
Reusing one solution for similar tasks: the same check is needed on several inputs, so write it once as a function → define checkMark(mark)
Q4
Spotting a repeated data entry step: the same input and store steps happen for each item, so one loop covers them → while more items: input item
Q5
input name1 input name2 input name3 input name4 → The repeated input steps were written out one by one, so the pattern was missed. A loop should repeat one input step.
Q6
Make a different table design for every class, even though each class list has the same fields → The similar record structure was not recognised. One table design with the same fields can be reused for every class.
Section C: Definitions
Q1
pattern recognition — Spotting similarities or repeated features in sub-problems so that one solution can be reused for similar tasks, such as repeated data entry steps or similar record structures.
Section D: Fill in the Blanks
Q1
for i from 1 to 30 input mark total ← total + mark
Q2
define calcTotal(price, qty) return price * qty
Q3
define calcTotal(price, qty) return price * qty cost ← calcTotal(25, 2)
Q4
while count < 10 input name count ← count + 1
Q5
for i from 1 to 5 input mark total ← total + mark
Section E: Spot the Error
Q1
B — The same entry step repeats three times, so one for loop covers it. The loop header needs the keyword 'to': for i from 1 to 3.
Q2
D — One function can be reused for every similar price. It should return the final amount (total), not just the GST part.
Q3
B — Students and teachers share the same record pattern, so one Person record is reused. A name is text, so its type should be string.
Q4
D — The function is reused for similar tasks by calling it once per value. It takes one parameter, so each call needs a single argument: cube(3).
Q5
C — Each repeat follows the same data entry pattern: input name, input age, save. Line 3 should use input to get age, otherwise age is never entered.