Present the algorithm of binary search. , Data Structure & Algorithms

Assignment Help:

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];

 

 


Related Discussions:- Present the algorithm of binary search.

Example of single node with multiple elements, The class Element represents...

The class Element represents a single node that can be part of multiple elements on a hotplate and runs in its own thread. The constructor accepts the initial temperature and a hea

Doubly linked list, How does operations like insertion, deletion occur?

How does operations like insertion, deletion occur?

#title.structured programming, what do you understand by structured program...

what do you understand by structured programming?explain with eg. top down and bottem up programming technique

Infix expression into the postfix expression, Q. Write down an algorithm to...

Q. Write down an algorithm to convert an infix expression into the postfix expression.     Ans. Algo rithm to convert infix expression to post fix expression is given as

A binary tree in which levels except possibly the last, A binary tree in wh...

A binary tree in which if all its levels except possibly the last, have the maximum number of nodes and all the nodes at the last level appear as far left as possible, is called as

Efficient way of storing a sparse matrix in memory, Explain an efficient wa...

Explain an efficient way of storing a sparse matrix in memory.   A matrix in which number of zero entries are much higher than the number of non zero entries is called sparse mat

Storing street addresses with doubly linked lists, Write a C++ program with...

Write a C++ program with header and source les to store street addresses using the Doubly Linked List ADT. Modify the Node class from Lab Assignment 3 so that it becomes a node in

Number of operations possible on ordered lists and arrays, Q. Enumerate num...

Q. Enumerate number of operations possible on ordered lists and arrays.  Write procedures to insert and delete an element in to array.

Define binary tree, Define Binary Tree  A binary tree T is explained as...

Define Binary Tree  A binary tree T is explained as a finite set of nodes that is either empty or having of root and two disjoint binary trees TL, and TR known as, respectively

Determine relevancy and relative position of two polygons, Comparison Techn...

Comparison Techniques There are several techniques for determining the relevancy and relative position of two polygons. Not all tests may be used with all hidden-surface algori

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd