Bỏ qua nội dung

Lesson 71: Binary search

English

Halve it again and again

  • A linear search checks the items one by one from the start (lesson 48).
  • A binary search works only on sorted data. It looks at the middle item and throws away the half that cannot hold the target. Then it repeats with the half that is left.
  • low and high mark the part that is left; mid = (low + high) / 2 is its middle.

Đăng nhập hoặc tạo tài khoản

IGCSE, A-Level & AP