🧠Concept

Pick the right answer.

Concept · Q1
What is the first requirement for binary search to work correctly?
Concept · Q2
A sorted list has 1,000 items. What is the maximum number of steps binary search needs to find any item?
Concept · Q3
In binary search, what happens when item(mid) is less than the target?
Concept · Q4
A student computes mid = (low + high) / 2 with no floor. Here low = 1 and high = 8. What is mid, and what goes wrong?

👀Code Reading

Look at the blocks. Predict what happens.

Code Reading · CR1
The sorted list is [3, 7, 11, 15, 22, 30] and target is 22. What happens during the first loop iteration?
when flag clicked
set [low v] to (1)
set [high v] to (length of [numbers v])
repeat until <(low) > (high)>
  set [mid v] to ([floor v] of (((low) + (high)) / (2)))
  if <(item (mid) of [numbers v]) = (target)> then
    say (join [Found at index ] (mid)) for (2) secs
    stop [this script v]
  else
    if <(item (mid) of [numbers v]) < (target)> then
      set [low v] to ((mid) + (1))
    else
      set [high v] to ((mid) - (1))
    end
  end
end
Code Reading · CR2
What does this script say when target is 99 and the sorted list is [10, 20, 30, 40, 50]?
when flag clicked
set [low v] to (1)
set [high v] to (length of [numbers v])
repeat until <(low) > (high)>
  set [mid v] to ([floor v] of (((low) + (high)) / (2)))
  if <(item (mid) of [numbers v]) = (target)> then
    say [Found!] for (2) secs
    stop [this script v]
  else
    if <(item (mid) of [numbers v]) < (target)> then
      set [low v] to ((mid) + (1))
    else
      set [high v] to ((mid) - (1))
    end
  end
end
say [Not in list!] for (2) secs
Code Reading · CR3
The sorted list is [5, 10, 15, 20, 25] and target is 15 (the middle item). How many times does the loop body run before the script stops?
when flag clicked
set [low v] to (1)
set [high v] to (5)
set [steps v] to (0)
repeat until <(low) > (high)>
  change [steps v] by (1)
  set [mid v] to ([floor v] of (((low) + (high)) / (2)))
  if <(item (mid) of [numbers v]) = (target)> then
    say (join [Found in ] (join (steps) [ steps])) for (2) secs
    stop [this script v]
  else
    if <(item (mid) of [numbers v]) < (target)> then
      set [low v] to ((mid) + (1))
    else
      set [high v] to ((mid) - (1))
    end
  end
end

🐛Find the Bug

Something is broken. Pick the fix.

The binary search almost always says "Not in list!" even when the target is in the sorted list. The student confirmed the list contains the target value. What is wrong?

when flag clicked
set [low v] to (1)
set [high v] to (length of [numbers v])
repeat until <(low) > (high)>
  set [mid v] to ([floor v] of (((low) + (high)) / (2)))
  if <(item (mid) of [numbers v]) = (target)> then
    say [Found!] for (2) secs
    stop [this script v]
  else
    if <(item (mid) of [numbers v]) < (target)> then
      set [high v] to ((mid) - (1))
    else
      set [low v] to ((mid) + (1))
    end
  end
end
say [Not in list!] for (2) secs

🛠️Build It

Pick a level. Build it. Check the boxes.

🧑‍🏫
For the teacher

Review the student's project, then check each thing they did.

Project Evaluation

0 of 4 ticked

💬Talk About It

Present your project to your teacher or a classmate.

  1. 1️⃣Show your binary search project.
  2. 2️⃣Point to your sorted list.
  3. 3️⃣Run it once and say the index it found.
🧑‍🏫
For the teacher

Watch the student present, then check each thing they did.

Presentation Checklist

0 of 3 ticked

📤Submit

Send your results to your teacher and parent.

0 of 0 answered