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
i want to write code for unification algorithm with for pattern matching between two expression with out representing an expression as alist

What is Algorithm A finite sequence of steps for accomplishing some computational task. An algorithm should Have steps which are simple and definite enough to be done

What is the best case complexity of quick sort In the best case complexity, the pivot is in the middle.

Write down the algorithm of quick sort. An algorithm for quick sort: void quicksort ( int a[ ], int lower, int upper ) {  int i ;  if ( upper > lower ) {   i = split ( a,

write an algorithm and draw a flowchart to calculate the perimeter and area of a circle

When writing a code for a program that basically answers Relative Velocity questions how do you go at it? How many conditions should you go through?

A Binary Search Tree is binary tree which is either empty or a node having a key value, left child & right child. By analyzing the above definition, we notice that BST comes int

The Linked list is a chain of structures wherein each structure contains data in addition to pointer, which stores the address (link) of the next logical structure in the list.

write a pseudocode to input the top speed (in km''s/hours) of 5000 cars output the fastest speed and the slowest speed output the average (mean) speed of all the 5000 cars answers

what is far and near procedures in system programming?