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
What do you understand by tree traversal? The algorithm walks by the tree data structure and performs some computation at everynode in the tree. This process of walking by the

1. For the ER diagram you created in assignment, the artefact of the conceptual database design, map the ER model into the relational model according to how it was designed in the

I need to know about data structure and algorithms. can you help me?

floyd warshall algorithm

Write an assembly program to separate the number of positive numbers and negative numbers from a given series of signed numbers.

A binary search tree is used to locate the number 43. Which of the following probe sequences are possible and which are not? Explain. (a) 61 52 14 17 40 43 (b) 2 3 50 40 60 43 (c)

After going through this unit, you will be able to: • define and declare Lists; • understand the terminology of Singly linked lists; • understand the terminology of Doubly

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

There are three typical ways of recursively traversing a binary tree. In each of these, the left sub-trees & right sub-trees are visited recursively and the distinguishing feature

Asymptotic notation Let us describe a few functions in terms of above asymptotic notation. Example: f(n) = 3n 3 + 2n 2 + 4n + 3 = 3n 3 + 2n 2 + O (n), as 4n + 3 is of