Write an algorithm for binary search., Data Structure & Algorithms

Write an algorithm for binary search.

Algorithm for Binary Search

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 a[mid-1]
8.  else
9.  search for X in a[mid+1] to a[high] 

Posted Date: 5/10/2013 5:14:26 AM | Location : United States







Related Discussions:- Write an algorithm for binary search., Assignment Help, Ask Question on Write an algorithm for binary search., Get Answer, Expert's Help, Write an algorithm for binary search. Discussions

Write discussion on Write an algorithm for binary search.
Your posts are moderated
Related Questions
What is Class invariants assertion A class invariant is an assertion which should be true of any class instance before and after calls of its exported operations. Generally

Which of the sorting algorithm is stable   Heap sorting is stable.

The process of accessing data stored in a serial access memory is same to manipulating data on a By using stack  method.

The following formula is used to calculate n: n = x * x/(1 - x) . Value x = 0 is used to stop algorithm. Calculation is repeated using values of x until value x = 0 is input. There

QUESTION (a) Define a tree and list its properties. (b) By showing all your workings, draw the spanning tree for the following graph based on the Breadth-First-Search algori

write an algorithm to find the average number of occurances of MECHANIL in an english passage

infix to revrse polish

The time needed to delete a node x from a doubly linked list having n nodes is O (1)

The following DNA sequences are extracted from promoter region of genes which are co-regulated by the same transcription factor (TF). The nucleotide segments capitalized in the giv

In the amortized analysis, the time needed to perform a set of operations is the average of all operations performed. Amortized analysis considers as a long sequence of operations