Present the algorithm of binary search. , Data Structure & Algorithms

Binary Search Algorithm is given as follows

1. if (low > high)

2.     return (-1)

3. mid = (low +high)/2;

4. if ( X = = a [mid])

5.      return (mid);

6. if ( X < a [mid])

7.    search for X in a (low) to [mid -1];

8.    else

9.     search for X in a [mid + 1] to a [high];

 

 

Posted Date: 7/13/2012 1:27:42 AM | Location : United States







Related Discussions:- Present the algorithm of binary search. , Assignment Help, Ask Question on Present the algorithm of binary search. , Get Answer, Expert's Help, Present the algorithm of binary search. Discussions

Write discussion on Present the algorithm of binary search.
Your posts are moderated
Related Questions
Define Wire-frame Model This skeletal view is called a Wire-frame Model. Although not a realistic representation  of the object, it is still very useful in the early stages of

Declaring a two dimensional array   A two dimensional array is declared same to the way we declare a one-dimensional array except that we state the number of elements in both di

Write an algorithm in the form of a flowchart that: inputs top speeds (in km/hr.) of 5000 cars Outputs fastest speed and the slowest speed Outputs average (mean) s

Explain an efficient way of storing two symmetric matrices of the same order in memory. A n-square matrix array is said to be symmetric if a[j][k]=a[k][j] for all j and k. For

what is alphanumerical code

Spanning Trees: A spanning tree of a graph, G, refer to a set of |V|-1 edges which connect all vertices of the graph. There are different representations of a graph. They are f

This unit dealt along with the methods of physically storing data in the files. The terms fields, records & files were described. The organization types were introduced. The sev

Q. An, array, A comprises of n unique integers from the range x to y(x and y inclusive where n=y-x). Which means, there is only one member that is not in A. Design an O(n) time alg

Question 1 Explain how the shuttle sort algorithm works by making use of the following list of integers:11, 4, 2, 8, 5, 33, 7, 3, 1, 6. Show all the steps. Question 2

What are expression trees?  The leaves of an expression tree are operands, like as constants or variable names, and the other nodes have operators. This certain tree happens to