Computational Thinking

Table of Contents

Binary search

an efficient algorithm to search position of element in a sorted list

belongs to the “Divide and Conquer” strategy (divide into subproblems into smallest is solved, solve subproblems recursively, combine all solutions)

average faster than linear search

How it works: works by comparing the search key K with the middle element A[m] of the list

middle element found by: subtract array.length-1, divide by 2, round up

then:

Performance:

Time complexity: