CS Grade 6-8

CS: Problem Solving with Algorithms

Design, trace, test, and improve step-by-step solutions

View Answer Key
Name:
Date:
Score: / 15

Design, trace, test, and improve step-by-step solutions

CS - Grade 6-8

Instructions: Read each problem carefully. Show your work in the space provided.
  1. 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. 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. 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. 4
    A robot on the bottom-left of a four-by-four grid with a target at the top-right and arrows showing up and right moves.

    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. 5
    Three quiz papers go through a calculator and gear, producing one report sheet.

    For an algorithm that calculates the average of three quiz scores, identify the input, process, and output.

  6. 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. 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. 8
    Two search methods are compared: checking cards one by one and narrowing a list by halves.

    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. 9

    Write an algorithm that decides whether a number is even or odd.

  10. 10

    Decompose the problem of planning a class party into at least four smaller tasks that could each have its own algorithm.

  11. 11

    Trace this loop: Set count to 0. Repeat 5 times: add 2 to count. Report count. What value is reported?

  12. 12
    A blank flowchart branches from a decision diamond to a green check result and a retry result.

    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. 13
    Two card sorting methods are shown: repeated whole-hand checking and selecting cards into an ordered row.

    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. 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. 15
    A robot in a maze moves toward a wall and turns right, with a nearby dead-end or loop.

    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.

LivePhysics™.com CS - Grade 6-8

More CS Worksheets

See all CS worksheets

More Grade 6-8 Worksheets

See all Grade 6-8 worksheets