Professional Documents
Culture Documents
Cse 36
Cse 36
A Simple C Programming
Presented by
Robiul Ibne Ali
ID:CSE-36
Registration no:17502004435
Department of Computer Science and Engineering
Supervised by
MD.Hemaet Uddin
Department of Computer Science and Engineering
Dhaka Commerce College
Presentation Outlines:
Introduction
Problem Statement
What is binary search algorithm?
Programming Code
Output
Introduction
■ Binary search works on sorted arrays. Binary search begins by comparing an element in the
middle of the array with the target value. If the target value matches the element, its position
in the array is returned. If the target value is less than the element, the search continues in the
lower half of the array. If the target value is greater than the element, the search continues in
the upper half of the array. By doing this, the algorithm eliminates the half in which the
target value cannot lie in each iteration
Problem Statement
if(array[middle]<search)
first=middle+1;
else if(array[middle]==search)
{
printf("%d is found at location %d",search,middle+1);
break;
}
else
last=middle-1;
middle=(first+last)/2;
}
if(first>last)
printf("Not found!%d isn't present in the Array",search);
}
Output: