1,877 views

1 Answer

1 votes
1 votes
See the following part of the code for binary search:

if(A[mid]==num)

{

    return mid;

}

else if(A[mid]<num)

{

   return bsearch(A,low,mid-1);

}

else

{

    return bsearch (A,mid+1,high);

}

 

Here 2 comparison in worst case for every recursive call

T(n)=T(n/2) +2

Related questions

1.3k
views
1 answers
1 votes
Pooja Khatri asked Jul 13, 2018
1,264 views
Let $R_1(a, b, c)$ and $R_2(x, y, z)$ be two relations in which a is the foreign key of $R_1$ ... b and c will cause violationOperations c and d will cause violationOperations d and a will cause violation
895
views
2 answers
1 votes
rajoramanoj asked Nov 6, 2017
895 views
3.3k
views
1 answers
3 votes
iita asked Jan 19, 2017
3,316 views
The number of BST possible with 6 nodes numbered 1, 2, 3, 4, 5 and 6 with exactly one leaf node __________
405
views
1 answers
1 votes
Aditya asked Nov 6, 2015
405 views