Practice using algorithms to solve problems, write pseudocode, trace steps, find bugs, and compare solutions.
Read each problem carefully. Show your work in the space provided.
Design, trace, test, and improve step-by-step solutions
CS - Grade 6-8
- 1
Write an algorithm with 5 to 7 clear steps for brushing your teeth. Each step should be specific enough for someone else to follow.
- 2
The steps below are out of order for finding the largest number in a list. Put them in the correct order: A. Compare each remaining number to largest. B. Report largest. C. Set largest to the first number in the list. D. If a number is greater than largest, replace largest with that number.
- 3
Trace this algorithm using the list [3, 6, 2, 8]: Set total to 0. For each number in the list, add the number to total. After the loop, report total. What value is reported?
- 4
A robot starts at the bottom-left square of a 4 by 4 grid and must reach the top-right square. It can only move up or right. Write one possible algorithm using exactly 6 moves.
- 5
For an algorithm that calculates the average of three quiz scores, identify the input, process, and output.
- 6
Find the bug in this algorithm for counting the number of students in a line: For each student in the line, add 1 to count. Report count. What important step is missing?
- 7
Write pseudocode for deciding whether to bring an umbrella. The algorithm should use the condition: if the forecast says rain, bring an umbrella; otherwise, do not bring one.
- 8
A sorted list has 1,000 names. Student A checks each name from the beginning until the target is found. Student B repeatedly cuts the search area in half. Which algorithm is usually more efficient, and why?
- 9
Write an algorithm that decides whether a number is even or odd.
- 10
Decompose the problem of planning a class party into at least four smaller tasks that could each have its own algorithm.
- 11
Trace this loop: Set count to 0. Repeat 5 times: add 2 to count. Report count. What value is reported?
- 12
A flowchart starts at Start, then asks Is score 70 or higher? If yes, it goes to Report pass. If no, it goes to Report try again. What output happens for a score of 68?
- 13
Two algorithms solve the same problem of sorting cards from lowest to highest. Algorithm 1 checks the whole hand over and over until all cards are in order. Algorithm 2 finds the lowest remaining card each time and places it next. Which algorithm sounds more organized, and why?
- 14
Create three test cases for an algorithm that reports whether a number is positive, negative, or zero. Include one expected output for each test case.
- 15
A maze-solving algorithm says: Move forward until you hit a wall. Turn right. Repeat. Give one reason this algorithm might fail in some mazes and suggest one improvement.