GRADE 8 · COMPUTING · UNIT 1 · LESSON 1.16

Computational thinking and programming

An unsuccessful search and termination

Read a little. Try the workbook. Check your answers. Choose one section below to get started.

Topic 1.16 · An unsuccessful search and termination8 fillable worksheet pagesRead at your own pace

LET’S TRACE, REASON AND TEST

An unsuccessful search and termination

An unsuccessful search must terminate after the final item has been checked. Keep the not-found result distinct from a valid position. Never read beyond the collection to decide whether it contains a match.

Today’s two goals
  • Check every item before declaring absence; explain why an end-of-collection check is essential.
  • Explain my method and support it with a labelled trace, example or test record.
Original PaxaKids illustration for An unsuccessful search and termination. Use the supplied program and data models for precise workbook facts.
An original PaxaKids workbook scene. Use the supplied programs and data for precise workbook facts.

Work through an example

Searching [2, 5, 8] for 7 makes three comparisons and then reports not found. It does not invent a fourth card or keep searching forever.

Try before your workbook

How many comparisons does a linear search need when the target is absent from a collection of four cards?

Explore the clues

Tap one card to find out more.

Understand the idea

An unsuccessful search must terminate after the final item has been checked. Keep the not-found result distinct from a valid position. Never read beyond the collection to decide whether it contains a match.

Concept to practise: An unsuccessful search and termination.

Work through an example

Searching [2, 5, 8] for 7 makes three comparisons and then reports not found. It does not invent a fourth card or keep searching forever.

Try before your workbook

How many comparisons does a linear search need when the target is absent from a collection of four cards?

Check my readiness thinking

Four, if every card must be checked once. The search then terminates with a not-found result.

Your original programs and learning models

These original PaxaKids program and data models support your workbook. Some examples deliberately contain faults to investigate. Follow their headings and preserve exact code case, punctuation and order. Traces and supplied records are not claims of physical testing.

Absence needs evidence from the whole collection

A first nonmatch proves only that the current item is not the target. If unchecked items remain, continue in order. An unsuccessful linear search reports not found only after every item in its defined collection has been checked.

When no items remain, stop rather than trying to read beyond the collection. For an empty collection, there are no value comparisons to perform.

Inspect every item before reporting not found

This original four-item collection contains key, globe, cone and drum in that order. The target is kite. Each snapshot reveals only the inspected value; the last one also reaches the end of the collection.
Inspect every item before reporting not found — original labelled workbook model. The following text version gives its labels and values.
Inspect every item before reporting not found · original PaxaKids model.
Read this model’s labels and values
Items
  1. key
  2. globe
  3. cone
  4. drum
Target
kite
Inspections
  1. 1
  2. 2
  3. 3
  4. 4

Trace an absent equipment target: positions 1–4

The full original C03 order is magnet, lens, whistle, ruler, compass, lens, torch. Target bell is compared exactly with each label. Keep the same target throughout.
Trace an absent equipment target: positions 1–4 — original model
Pos.Value inspectedMatches bell?Next action
1magnet{'clue': 'Yes or No', 'prompt': 'Bell search: position 1 match', 'answers': ['No']}{'clue': 'Stop or continue', 'prompt': 'Bell search: action after position 1', 'answers': ['Continue']}
2lens{'clue': 'Yes or No', 'prompt': 'Bell search: position 2 match', 'answers': ['No']}{'clue': 'Stop or continue', 'prompt': 'Bell search: action after position 2', 'answers': ['Continue']}
3whistle{'clue': 'Yes or No', 'prompt': 'Bell search: position 3 match', 'answers': ['No']}{'clue': 'Stop or continue', 'prompt': 'Bell search: action after position 3', 'answers': ['Continue']}
4ruler{'clue': 'Yes or No', 'prompt': 'Bell search: position 4 match', 'answers': ['No']}{'clue': 'Stop or continue', 'prompt': 'Bell search: action after position 4', 'answers': ['Continue']}

Finish the absent-target trace: positions 5–7

Continue the same bell search. At the final position, check the value before deciding that the collection is exhausted. Stop means stop with not found here, because no value matched.
Finish the absent-target trace: positions 5–7 — original model
Pos.Value inspectedMatches bell?Next action
5compass{'clue': 'Yes or No', 'prompt': 'Bell search: position 5 match', 'answers': ['No']}{'clue': 'Stop or continue', 'prompt': 'Bell search: action after position 5', 'answers': ['Continue']}
6lens{'clue': 'Yes or No', 'prompt': 'Bell search: position 6 match', 'answers': ['No']}{'clue': 'Stop or continue', 'prompt': 'Bell search: action after position 6', 'answers': ['Continue']}
7torch{'clue': 'Yes or No', 'prompt': 'Bell search: position 7 match', 'answers': ['No']}{'clue': 'Stop or continue', 'prompt': 'Bell search: action after position 7', 'answers': ['Stop']}

Handle an empty collection before reading an item

Handle an empty collection before reading an item — original model
StageOriginal plain-language search instructions
Before inspectionIf the collection has no items, report not found and stop.
InspectStart at the first item and compare its value with the unchanged target.
On a matchReport the current position and stop.
On a nonmatchIf another item remains, move to it and repeat the comparison.
On exhaustionIf no item remains after a nonmatch, report not found and stop.

Prepare the original hidden-number-card practice

The fixed order shown is 18, 7, 32, 11, 24, 5. For an actual card round, copy all six values, shuffle them and place them face down in a row. Reveal one at a time in position order. Use actual shuffled positions when recording that round.
Prepare the original hidden-number-card practice — original labelled workbook model. The following text version gives its labels and values.
Prepare the original hidden-number-card practice · original PaxaKids model.
Read this model’s labels and values
Labels
  1. 18
  2. 7
  3. 32
  4. 11
  5. 24
  6. 5

Files for this activity

Use these original PaxaKids practice files with the matching workbook. Work on a local copy in the appropriate editor. Some examples deliberately contain faults to investigate; a downloaded file is not a completed practical test.

Paxa the Fox

Try one step with Paxa!

Trace code in the stated order and preserve exact spelling and case. Use fictional data. Label a prediction, paper trace, simulator run and physical-device test separately; an unperformed test stays Pending. Save personal responses before leaving.

Our Unit 1 learning path
  1. Lesson 1.1: Recall algorithms and representations
  2. Lesson 1.2: Purpose and conventions of pseudocode
  3. Lesson 1.3: Input, output and strings
  4. Lesson 1.4: Identifiers and assignment
  5. Lesson 1.5: Arithmetic and translation
  6. Lesson 1.6: Trace and review a sequence
  7. Lesson 1.7: Conditions and two-way flow
  8. Lesson 1.8: IF THEN and indentation
  9. Lesson 1.9: IF THEN ELSE and decision diagrams
  10. Lesson 1.10: Ordered ELSEIF and fallback ELSE
  11. Lesson 1.11: Match flowchart and pseudocode branches
  12. Lesson 1.12: AND, OR and NOT
  13. Lesson 1.13: Grouping, precedence and review
  14. Lesson 1.14: Why software searches
  15. Lesson 1.15: A successful linear search
  16. Lesson 1.16: An unsuccessful search and termination
  17. Lesson 1.17: Practise and communicate the search
  18. Lesson 1.18: Translate conditions into Python
  19. Lesson 1.19: One-branch IF programs
  20. Lesson 1.20: Two-way IF ELSE programs
  21. Lesson 1.21: Ordered ELIF choices
  22. Lesson 1.22: Ranges and independent decisions
  23. Lesson 1.23: Boolean operators in Python
  24. Lesson 1.24: Design and test recommendations
  25. Lesson 1.25: Trace, debug and reflect
  26. Lesson 1.26: Choose data types and recognise Boolean literals
  27. Lesson 1.27: Set and use Boolean flags
  28. Lesson 1.28: Explain and identify constants
  29. Lesson 1.29: Express constants in three algorithm forms
  30. Lesson 1.30: Use a fixed factor in a calculation
  31. Lesson 1.31: Cast to Boolean and validate an empty response
  32. Lesson 1.32: Recall calls and trace return values
  33. Lesson 1.33: Supply parameters and reuse library code
  34. Lesson 1.34: Choose and import libraries responsibly
  35. Lesson 1.35: Round with floor and ceiling
  36. Lesson 1.36: Use pi and investigate another mathematical feature
  37. Lesson 1.37: Generate random choices within bounds
  38. Lesson 1.38: Investigate random real values and review library use
  39. Lesson 1.39: Retrieve test tables and predict selection outcomes
  40. Lesson 1.40: Decompose everyday problems
  41. Lesson 1.41: Decompose programs and organise shared work
  42. Lesson 1.42: Develop through repeated build/test cycles
  43. Lesson 1.43: Predict and verify algorithm outcomes
  44. Lesson 1.44: Choose representative and boundary tests
  45. Lesson 1.45: Build, execute and review a test plan
  46. Lesson 1.46: Recall physical inputs and compare transmission media
  47. Lesson 1.47: Configure a radio group and agree a message scheme
  48. Lesson 1.48: Send and receive numbers and strings
  49. Lesson 1.49: Trace numeric message sequences
  50. Lesson 1.50: Transmit text and use received data in conditions
  51. Lesson 1.51: Diagnose and extend a message protocol
  52. Lesson 1.52: Review communication and evidence of testing
  53. Lesson 1.53: Project 1: Adventure story
  54. Lesson 1.54: Project 2: Fire, Water, Earth
  55. Lesson 1.55: Check your progress 1
For grown-ups: using this lesson

Your answers are checked in your browser. Open responses need grown-up review and are shown separately from the automatic score. Check your work, then use “Retry answers to practise” to revisit mistakes while keeping correct responses.

Read one explanation, discuss the model and try the readiness check before the workbook. Choose “Mark lesson finished” when ready. Optional account progress saves lesson position and completion across devices; save personal responses before leaving.

2. Fill in your workbook

Read the teaching and complete workbook instructions. Choose, write or draw; Answer list offers larger controls. Trace code precisely and distinguish predictions from actual tests. Review designs, explanations and drawings with a grown-up.

An unsuccessful search and termination8 student pages · original artwork

Opening your PDF…

Swipe sideways across the worksheet on a small screen, or use “Answer list” for larger controls.

TAKE YOUR PRACTICE OFFLINE

3. Download the student worksheet

All 8 original A4 student pages, ready for pencil-and-paper practice. Choose Review Answers to check your work on this webpage.

Student worksheet only · PDF · 8.2 MiB · No answer key included

Download worksheet PDF ↓

TRY FIRST, THEN CHECK TOGETHER

Download the student worksheet →

4. Answers & guidance

Finished your try? Open the guide and compare one worksheet at a time. Your own words may be different and still explain the right idea.

Shown on this webpage only. There is no answer-key download, and this guide is left out when printing the page.

Show answers for all 8 worksheets

Worksheet 1

  1. Question 1: After the first nonmatch in a longer collection, what is justified? the current value does not match; later values still need checking
  2. Question 2: What ends an unsuccessful linear search? all available items have been checked without a match

Worksheet 2

This page introduces the activity. There are no marked responses on this sheet.

Worksheet 3

  1. Question 3: Bell search: position 1 match No
  2. Question 4: Bell search: action after position 1 Continue
  3. Question 5: Bell search: position 2 match No
  4. Question 6: Bell search: action after position 2 Continue
  5. Question 7: Bell search: position 3 match No
  6. Question 8: Bell search: action after position 3 Continue
  7. Question 9: Bell search: position 4 match No
  8. Question 10: Bell search: action after position 4 Continue

Worksheet 4

  1. Question 11: Bell search: position 5 match No
  2. Question 12: Bell search: action after position 5 Continue
  3. Question 13: Bell search: position 6 match No
  4. Question 14: Bell search: action after position 6 Continue
  5. Question 15: Bell search: position 7 match No
  6. Question 16: Bell search: action after position 7 Stop
  7. Question 17: How many value comparisons are made for this bell search? 7
  8. Question 18: Which evidence justifies not found? every one of the seven values was compared with bell and none matched

Worksheet 5

  1. Question 19: How many value comparisons does a search of an empty collection make? 0
  2. Question 20: Why should an empty collection not inspect position 1? no item exists there

Worksheet 6

  1. Question 21: In the fixed printed layout, where is target 11 found? 4
  2. Question 22: For absent target 99 in this six-item layout, how many comparisons are needed? 6

Worksheet 7

  1. Question 23: Use all six page 6 values to make a hidden row, or use its fixed layout for an explicitly labelled manual route. Perform separate linear searches for 18, 5 and absent target 99. Record each target, actual layout, every inspected position/value and comparison result, final result and comparison count. Shuffle and repeat one search if physical cards are available. If working with a partner, compare methods and then complete a separate individual search. State what you actually did and leave unavailable physical, shuffle or partner stages Pending. Retain Unplugged 1.9 hidden-number-card repeated search and independent follow-up with complete original values 18, 7, 32, 11, 24, 5. Actual shuffled successful positions/counts vary; target 99 absent always requires 6 comparisons. Fixed-layout route: 18 position 1/count 1; 5 position 6/count 6; 99 not found/count 6, all positions inspected. No skipped/repeated cards in linear routine; end checked before reading beyond. Actual repeat/individual/peer evidence or honest Pending, not invented results. Count data are not marks. Grown-up review; personal evidence is required.

Worksheet 8

  1. Question 24: A proposed instruction says: compare the first item; if it does not match, report not found and stop. Explain why this is wrong for a collection with later items. Replace it with complete instructions that handle a match, a nonmatch with another item available, exhaustion and an empty collection. Test your corrected plan on the page 2 collection for target drum and then target kite. Show inspected positions, final results and comparison counts, and explain why the same count can accompany different results. Identify your trace or actual demonstration method and any practical or peer step still Pending. Fault stops after first failure and can miss later match. Correct plan checks empty first, compares consecutive items with same target, stops on first match, continues after nonmatch when another exists, otherwise not found/stop. key/globe/cone/drum target drum: positions 1–4, first 3 no, last yes -> found position 4/count 4. Target kite: all 4 no ->not found/count 4. Same comparisons but different last comparison truth/result; no inspection beyond final item. Empty ->not found/count 0. Require complete corrected instructions, exact trace and honest evidence/Pending, no numeric grading. Grown-up review; personal evidence is required.
Back to my workbook ↑

Curriculum & workbook reference

Computing for your homeschool day

Explore An unsuccessful search and termination with this free Grade 8 Computing lesson. Read one idea together, try the fillable workbook and return to review at your own pace. Download the same student worksheet PDF for pencil-and-paper practice.

Fit learning around your family’s day. There is no timer and no sign-up is needed to use the lesson. An optional account saves your lesson position and completion across devices. Workbook responses and drawings stay in this tab; save a copy of your responses before leaving.

Understand your results

Closed answers are checked in your browser. Drawings and written explanations need grown-up review and are shown separately from the automatic score. Check your work, then use “Retry answers to practise” to revisit mistakes while keeping correct responses.

Choose Review Answers after trying the activity. The guide stays on the webpage; the worksheet download contains only the student pages.

For programme background, visit the Cambridge Lower Secondary Computing overview. PaxaKids provides independent original companion practice.

Book page references identify the related teaching topic. File-management and responsible-data preparation are original PaxaKids material; orientation or contents pages are not presented as teaching citations for those skills. The explanations, characters, programs and exercises here are original PaxaKids companion practice. Practical tasks require the appropriate editor and, where applicable, suitable equipment. A design or paper trace is not a verified hardware result. Only completed, reviewed lessons are listed.

Explore the Cambridge Lower Secondary Computing curriculum for programme background. PaxaKids is an independent learning resource.