Big Idea 3 · Topic 3.10 · Exercise 2
Traverse and Search
25 minutes - Predict the output of 5 traversal and search algorithms
Back to the Topic 3.10 lessonAll CSP topics
How this page works
The writing boxes below are yours. What you type stays in this browser, is saved here as you go, and is never sent to us or to your teacher. Hand the written work in the way your teacher asked for it.
The graded check at the bottom is the part that records to your teacher's gradebook.
The cases, from your handoutNot recorded
The same cases as your handout, in the same order.
Scenario 1 · Foundational
total <- 0; FOR EACH day IN steps { total <- total + day }; DISPLAY(total). What is displayed?
The running value and its starting value:
The running value after each pass (trace it):
Final displayed output (+ enrichment note):
Scenario 2 · Core
count <- 0; FOR EACH day IN steps { IF(day >= 10000) { count <- count + 1 } }; DISPLAY(count). What is displayed?
The running value and its starting value:
The running value after each pass (trace it):
Final displayed output (+ enrichment note):
Scenario 3 · Core
best <- steps[1]; FOR EACH day IN steps { IF(day > best) { best <- day } }; DISPLAY(best). What is displayed?
The running value and its starting value:
The running value after each pass (trace it):
Final displayed output (+ enrichment note):
Scenario 4 · Challenge
A linear search scans steps in order for the value 9000, stopping as soon as it is found, and displays the 1-indexed position. What is displayed, and how many elements were examined?
The running value and its starting value:
The running value after each pass (trace it):
Final displayed output (+ enrichment note):
Scenario 5 · Challenge
total <- 0; FOR EACH day IN steps { total <- total + day }; DISPLAY(total / LENGTH(steps)). What is displayed, and why is dividing by LENGTH better than dividing by 5?
The running value and its starting value:
The running value after each pass (trace it):
Final displayed output (+ enrichment note):
No graded check on this page yetNot recorded
About the line in your handout
Your handout says this exercise is available online and auto-graded. The exercise IS here, and it is the same work in the same order, but the auto-graded half is not written for this topic yet. Nothing on this page is scored or sent to your teacher.
Hand this in the way your teacher asked for it. Topic 1.1 has its graded check today, and the rest follow.