Computer Science - Algorithms - Binary search - Binary Search Algorithm

5 steps. Step 1 'Prerequisites': Array MUST be sorted! If not sorted, sort first or use linear search. Step 2 'The Algorithm': def binary_search(arr, target): low, high = 0, len(arr)-1; while low <= high: mid = (low+high)//2; if arr[mid] == target: return mid; elif arr[mid] < target: low = mid+1; el

Edodovivmagarwal
Computer Science - Algorithms - Binary search - Binary Search Algorithm
Log in

Preparing your experience...

Loading scripts and resources

Comments (0)

0/5000

Comments are reviewed before appearing publicly.

About this Experience

Computer Science - Algorithms - Binary search - Binary Search Algorithm

vivmagarwal
vivmagarwalJan 29, 2026

Description

5 steps. Step 1 'Prerequisites': Array MUST be sorted! If not sorted, sort first or use linear search. Step 2 'The Algorithm': def binary_search(arr, target): low, high = 0, len(arr)-1; while low <= high: mid = (low+high)//2; if arr[mid] == target: return mid; elif arr[mid] < target: low = mid+1; el

Details

Computer ScienceAlgorithmsClass 9, Class 9, Stage 9, Grade 9, MYP Year 4

Engagement

19

Likes

0

Remixes

0

Comments