Worksheets › Class 7 › Algorithms with Branching: Sorting and Searching

Class 7 · Computational Thinking and AI worksheet

Algorithms with Branching: Sorting and Searching

CBSE Computational Thinking and AI. If–otherwise traces, one pass of bubble sort, linear search, halving guesses and finding the wrong step. Every sheet has 20 questions in three sections and an answer key, and the questions change every time.

Open a printable sample sheet

Sample questions

Real questions from this chapter, as the app sets them. Tap Answer to see the answer and working.

Section A · multiple choice

  1. 1.

    An "if … otherwise …" step in an algorithm is called:

    1. a variable
    2. an input
    3. a loop
    4. branching (a condition)
    Answer

    (d) branching (a condition)

  2. 2.

    x = 63 Repeat 7 times: If x is even, x = x ÷ 2 Otherwise, x = x + 5 What is x at the end?

    1. 8
    2. 16
    3. 13
    4. 9
    Answer

    (a) 8

    63 → 68 → 34 → 17 → 22 → 11 → 16 → 8

  3. 3.

    Go along the list comparing each pair of neighbours from the left, and swap them if the left one is bigger (one pass of bubble sort). What is the list after one pass? 16, 1, 40, 6, 8

    1. 40, 8, 6, 16, 1
    2. 1, 6, 8, 16, 40
    3. 1, 16, 6, 8, 40
    4. 16, 1, 40, 6, 8
    Answer

    (c) 1, 16, 6, 8, 40

    3 swaps; the largest number moves to the end

Section B · short answer

  1. 4.

    What is branching in an algorithm?

    Answer

    Choosing between different steps depending on whether a condition is true or false.

  2. 5.

    x = 44 Repeat 3 times: If x is even, x = x ÷ 2 Otherwise, x = x + 3 What is x at the end?

    Answer

    14

    44 → 22 → 11 → 14

Section C · long answer

  1. 6.

    Sort 7, 3, 9, 1, 5 using bubble sort. Write the list after each pass and count the swaps in each pass.

    Answer

    Pass 1: 3, 7, 1, 5, 9 (3 swaps). Pass 2: 3, 1, 5, 7, 9 (2 swaps). Pass 3: 1, 3, 5, 7, 9 (1 swap). Pass 4: no swaps: sorted.

Fresh sheets for your child

In the app, every Algorithms with Branching: Sorting and Searching sheet is new: the app remembers the questions your child has already had and leaves them out. Print the sheet as a PDF, or use notebook mode and write the answers in a notebook.

Coming soon for Android and iPhone.

More Class 7 Computational Thinking and AI