Teach Binary Search Algorithm with example

DivyaBoby1 0 views 15 slides Aug 28, 2025
Slide 1
Slide 1 of 15
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15

About This Presentation

Binay search algorithm teaching


Slide Content

Binary Search Algorithm

Searching

What is searching ? Searching is a process used to find the location of a target among a list of objects. e.g., where is 1 4 ?

Successful searching in an unordered list

Unsuccessful search in unordered list

Search Algorithms 6

Binary Search O(log2 n) A binary search looks for an item in a list using a divide-and-conquer strategy 7

Binary Search Binary search algorithm assumes that the items in the array being searched are sorted We start by dividing the array into 2 parts and look look for the item in the middle of the array in a binary search If the item we are searching is less than the item in the middle , we know that the item won’t be in the second half of the array. So we look in the 1 st half Once again we examine the middle element The process continues with each comparison cutting in half the portion of the array until we reach the location the item might be

Determine whether 22 is in the list Binary Search Algorithm Example Array list with twelve (12) elements 21 is less than 22, so we look in the 2 nd half

Binary Search Algorithm (Cont’d) Search list, list[6] … list[11] first = mid + 1

Binary search example 11 Mid =(6+11)/2 =8

Unsuccessful binary search example 12

Binary Search 13

Binary Search 14

15