Algorithm for finding a key by binary search technique, Data Structure & Algorithms

Q. Write down an algorithm for finding a key from a sorted list using the binary search technique or method.                                                                                                                      

Ans.

Binary Search Algorithm is written below

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 2:18:04 AM | Location : United States







Related Discussions:- Algorithm for finding a key by binary search technique, Assignment Help, Ask Question on Algorithm for finding a key by binary search technique, Get Answer, Expert's Help, Algorithm for finding a key by binary search technique Discussions

Write discussion on Algorithm for finding a key by binary search technique
Your posts are moderated
Related Questions
What are the different ways of representing a graph? The different ways of representing a graph is: Adjacency list representation: This representation of graph having of an

In this unit, we learned the data structure arrays from the application point of view and representation point of view. Two applications that are representation of a sparse matrix

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

Ask queConsider the following functional dependencies: Applicant_ID -> Applicant_Name Applicant_ID -> Applicant_Address Position_ID -> Positoin_Title Position_ID -> Date_Position_O

1.Create a flowchart to show the process that will allow the implementation of Stack, Push, and Pop operations. 2.Create a flowchart to show the process that will allow the impleme

I am looking for some help with a data mining class with questions that are about neural networks and decision trees. Can you help? I can send document with questions.

Q. Describe the term array.  How do we represent two-dimensional arrays in memory?  Explain how we calculate the address of an element in a two dimensional array.

Determine the Disjoint of division method A polygon is disjoint from the viewport if the x- and y-extents of the polygon do not overlap the viewport anywhere. In this case; reg

Algorithm to Delete a given node from a doubly linked list Delete a Node from Double Linked List DELETEDBL(INFO, FORW, BACK, START, AVAIL,LOC) 1. [Delete Node] Set FOR

Postorder traversal of a binary tree struct NODE { struct NODE *left; int value;     /* can take any data type */ struct NODE *right; }; postorder(struct NODE