Find the time complexity of Binary Search Algorithm.
Time complexity of binary search
In binary search each step of the algorithm divides the list of items being searched in half of the list.
So we can say that
T(n)= T(n/2) +1 where n>1
= T(n/4) +1 +1
= T(n/22) + 2
= T(n/23) +3
……………..
………………
=T(n/2k) + k
If n=2k then k= log2n
= T(1) + log2n
So
T(n)= O(log2n)
Best case condition occur when the element to be searched in first time. Then complexity is O(1).
"Write an algorithm to test whether a given binary tree is a binary search tree."
Define Quality Planning
What is an unrolled linked list?
What are Halstead’s metrics?
Write a C program to multiplication of two matrix.
Write a C program to find a number is AMSTRONG or NOT.