Skip to content
MathsGenie logo
Open app

Course home

  1. IGCSE
  2. Computer Science Edexcel
  3. Question bank

Algorithms

EasyMedium
123456789101112131415161718
Question 15

Study the following pseudocode algorithm which performs a binary search on a sorted array.

arr = [3, 7, 10, 15, 21, 28, 32, 40]
target = 32
low = 0
high = 7
found = False

while low <= high and found == False do
    mid = (low + high) DIV 2
    if arr[mid] == target then
        found = True
    else if arr[mid] < target then
        low = mid + 1
    else
        high = mid - 1
    endif
endwhile

Complete the trace table below to show the execution of this algorithm. Some initial values have been entered for you.

targetlowhighmidfound
3207False
[5]

Algorithms Questions

  1. IGCSE
  2. /Computer Science
  3. /Algorithms