Unit II - Session 9
Unit II - Session 9
Unit II - Session 9
Session – 9
Syllabus
Introduction, Binary Search - Merge sort and its
algorithm analysis - Quick sort and its algorithm
analysis - Strassen's Matrix multiplication - Finding
Maximum and minimum - Algorithm for finding closest
pair - Convex Hull Problem
Introduction
Divide/ Break
Conquer / Solve
Merge / Combine
BINARY SEARCH ALGORITHM
Binarysearch(a[n], key)
start=0; end=n-1;
While(start<=end)
{
mid=(start+end)/2;
return mid
if(a[mid]==key)
return mid;
else if(a[mid]<key)
end=mid-1;
else
start=mid+1;
}
return -1;
ANALYSIS
Using Master’s theorem
T(n) = T(n/2) + 1
T(n) = aT(n/b) + f(n) where a >= 1 and b > 1
a=1 b=2 f(n) = 1 = n0
3. If f(n) > Ω (nlogba), and f(n) satisfies the regularity condition, then T
(n) = ϴ (f(n)).