Sequence Examples in CS Thinking

Start with the recap, study the fully worked examples, then use the practice problems to check your understanding of Sequence.

This page combines explanation, solved examples, and follow-up practice so you can move from recognition to confident problem-solving in CS Thinking.

Concept Recap

Executing a series of instructions one after another in a fixed, specific order. In sequential execution, each instruction must complete before the next one begins, and the order in which statements appear determines the order in which they run.

Do this, then that, then the next thingβ€”order matters and each step must finish before the next.

Read the full concept explanation β†’

How to Use These Examples

  • Read the first worked example with the solution open so the structure is clear.
  • Try the practice problems before revealing each solution.
  • Use the related concepts and background knowledge badges if you feel stuck.

What to Focus On

Core idea: Each step must complete fully before the next step begins; the order determines the result.

Common stuck point: Some steps can't be reordered; others can. Understanding dependencies is key.

Sense of Study hint: When writing sequential code, think about which steps depend on results from earlier steps. If step B uses a value computed in step A, then A must come first. Trace through your sequence line by line to verify the order produces the correct result.

Common Mistakes to Watch For

Before you work through the examples, skim the mistake guide so you know which shortcuts and sign errors to avoid.

Worked Examples

Example 1

easy
What is the output of this sequence of instructions? SET x = 5. SET y = 3. SET z = x + y. OUTPUT z.

Solution

  1. 1
    Step 1: x is assigned 5.
  2. 2
    Step 2: y is assigned 3.
  3. 3
    Step 3: z = x + y = 5 + 3 = 8. Output: 8.

Answer

8
A sequence executes instructions one after another in order. The order matters β€” changing it would change the result.

Example 2

easy
Rearrange these steps into the correct sequence for logging into a website: (A) Click 'Login'. (B) Enter password. (C) Open browser. (D) Navigate to website. (E) Enter username.

Practice Problems

Try these problems on your own first, then open the solution to compare your method.

Example 1

easy
What is the output? SET a = 10. SET b = a * 2. SET a = 0. OUTPUT b.

Example 2

easy
Trace this pseudocode: SET x = 2. SET y = x + 4. SET x = y * 2. OUTPUT x, y.

Background Knowledge

These ideas may be useful before you work through the harder examples.

algorithm