AmbifulWorksheets
Practice that never repeats
CBSE · Class 7 · Computational Thinking and AI

Algorithms with Branching: Sorting and Searching

Standard difficulty · 20 questions · 40 marks · Time: 37 minutes

Name: Date: Score: ____ / 40

Show your working for Sections B and C. Answers are on the last page — try every question first!

Section A — Choose the correct answer8 × 1 = 8 marks
1.
An "if … otherwise …" step in an algorithm is called:
  1. a variable
  2. an input
  3. a loop
  4. branching (a condition)
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
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
4.
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). How many swaps are made in one pass on the list 1, 32, 21, 14, 26?
  1. 3
  2. 2
  3. 0
  4. 1
5.
A friend thinks of a whole number from 1 to 100. After each guess you are told "higher", "lower" or "correct". If you always guess the middle of the numbers left, what is the most guesses you could need?
  1. 50
  2. 6
  3. 8
  4. 7
6.
To find 42 in the list 36, 35, 19, 58, 30, 10, 42, you check the numbers one by one from the left. How many numbers do you check?
  1. 1
  2. 6
  3. 7
  4. 8
7.
Arjun starts with 16 and follows these steps, writing the number after each one:
Step 1: add 8 (Arjun writes 24)
Step 2: divide by 2 (Arjun writes 12)
Step 3: divide by 3 (Arjun writes 4)
Step 4: add 11 (Arjun writes 15)
Step 5: add 13 (Arjun writes 27)
One step was worked out wrongly, and the later steps were done correctly from it. Which step number is wrong?
  1. 2
  2. 1
  3. 5
  4. 3
8.
Start with the row H, R, B, M, N. (1) Reverse the whole row. (2) Move the first letter to the end. (3) Move the last letter to the front. (4) Reverse the whole row. Which letter is now in place 3?
  1. B
  2. R
  3. H
  4. M
Section B — Short answer8 × 2 = 16 marks
9.
What is branching in an algorithm?
10.
x = 44
Repeat 3 times:
If x is even, x = x ÷ 2
Otherwise, x = x + 3
What is x at the end?
11.
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? 3, 10, 39, 30, 34
12.
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). How many swaps are made in one pass on the list 32, 24, 13, 17, 30?
13.
A friend thinks of a whole number from 1 to 200. After each guess you are told "higher", "lower" or "correct". If you always guess the middle of the numbers left, what is the most guesses you could need?
14.
To find 30 in the list 52, 28, 36, 43, 3, 54, 19, 21, 30, 7, you check the numbers one by one from the left. How many numbers do you check?
15.
Nikhil starts with 18 and follows these steps, writing the number after each one:
Step 1: divide by 2 (Nikhil writes 9)
Step 2: divide by 3 (Nikhil writes 3)
Step 3: add 12 (Nikhil writes 15)
Step 4: multiply by 3 (Nikhil writes 48)
Step 5: take away 8 (Nikhil writes 40)
One step was worked out wrongly, and the later steps were done correctly from it. Which step number is wrong?
16.
A number machine does: divide by 2 → add 2 → add 11 → add 14. 30 came out. What number went in?
Section C — Word problems4 × 4 = 16 marks
17.
Sort 7, 3, 9, 1, 5 using bubble sort. Write the list after each pass and count the swaps in each pass.
18.
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). For the list 35, 18, 23, 10, 1: (a) what is the list after one pass? (b) How many swaps are made?
19.
(a) A friend thinks of a whole number from 1 to 60. After each guess you are told "higher", "lower" or "correct". If you always guess the middle of the numbers left, what is the most guesses you could need?
(b) To find 60 in the list 45, 47, 9, 35, 15, 31, 38, 58, 39, 60, you check the numbers one by one from the left. How many numbers do you check?
20.
(a) x = 15
Repeat 5 times:
If x > 22, x = x − 7
Otherwise, x = x + 7
What is x at the end?
(b) Start with the row K, J, G, R, C. (1) Move the first letter to the end. (2) Reverse the whole row. (3) Swap the letters in places 1 and 4. (4) Swap the letters in places 1 and 3. What is the row now?
AmbifulWorksheets
Practice that never repeats
CBSE · Class 7 · Computational Thinking and AI

Answer key

Algorithms with Branching: Sorting and Searching · AW-7CT-ALG-2026-V1 · For parents — fold back or tear off before handing the sheet to your child.

QAnswerWorking
1(d) branching (a condition)—
2(a) 863 → 68 → 34 → 17 → 22 → 11 → 16 → 8
3(c) 1, 16, 6, 8, 403 swaps; the largest number moves to the end
4(a) 3after the pass: 1, 21, 14, 26, 32
5(d) 7each guess about halves what is left; 63 < 100 ≤ 127
6(c) 742 is in place 7
7(c) 5step 5 should give 28, not 27
8(a) Bthe row ends as H R B M N
9Choosing between different steps depending on whether a condition is true or false.—
101444 → 22 → 11 → 14
113, 10, 30, 34, 392 swaps; the largest number moves to the end
124after the pass: 24, 13, 17, 30, 32
138each guess about halves what is left; 127 < 200 ≤ 255
14930 is in place 9
154step 4 should give 45, not 48
166undo each step from the end: 30 → 16 → 5 → 3 → 6
17Pass 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.—
18(a) 18, 23, 10, 1, 35; (b) 4compare 1st and 2nd, then 2nd and 3rd, and so on, swapping when the left is bigger
19(a) 6; (b) 10(a) each guess about halves what is left; 31 < 60 ≤ 63; (b) 60 is in place 10
20(a) 22; (b) R, C, G, K, J(a) 15 → 22 → 29 → 22 → 29 → 22; (b) carry out each instruction in order: R C G K J