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
In this project you will write a program to produce a discrete time simulation of a queue as shown in Fig. 1. Time is slotted on the input and the output. Each input packet follows

GIVE TRACE OF BINARY SEARCH ALGORITHM BY USING A SUITABLE EXAMPLE.

for i=1 to n if a[i}>7 for j=2 to n a[j]=a{j}+j for n=2 to n a[k]=a[j]+i else if a[1]>4 && a[1] for 2 to a[1] a[j]= a{j]+5 else for 2to n a[j]=a[j]+i ..

Given is the structure of an AVL tree: struct avl { struct node *left; int info; int bf; struct node *right; }; 2) A multiway tree of n order is an ord

Initially Nodes are inserted in an AVL tree in the same manner as an ordinary binary search tree. Though, the insertion algorithm for any AVL tree travels back along with the pa

Think of a program you have used that is unacceptably slow. Identify the specific operations that make the program slow. Identify other basic operations that the program performs q

Conversion of Forest into Tree A binary tree may be used to show an entire forest, since the next pointer in the root of a tree can be used to point to the next tree of the for

Explain what are circular queues? Write down routines required for inserting and deleting elements from a circular queue implemented using arrays.           Circular queue:

Explain the halting problem Given a computer program and an input to it, verify whether the program will halt on that input or continue working indefinitely on it.

A queue is a particular type of collection or abstract data type in which the entities in the collection are went in order and the principal functions on the collection are the add