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

Assignment Help:

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] 


Related Discussions:- Write an algorithm for binary search.

Er diagram, Ask queConsider the following functional dependencies: Applican...

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

Compound interest, Write the algorithm for compound interest

Write the algorithm for compound interest

Insert an element after an element pointed by some pointer, Consider a link...

Consider a linked list of n elements. What is the time taken to insert an element after an element pointed by some pointer? O (1)

Methods of collision resolution, Methods of Collision Resolution 1)  Co...

Methods of Collision Resolution 1)  Collision Resolution by separate chaining  2)  Collision Resolution by open addressing

The complexity of searching an element, The complexity of searching an elem...

The complexity of searching an element from a set of n elements using Binary search algorithm is   O(log n)

Hotel reservation system, pls i want a psuedo code for hotel reservation sy...

pls i want a psuedo code for hotel reservation system.

Algorithm to count number of nodes, Write an algorithm to count number of n...

Write an algorithm to count number of nodes in the circular linked list.                            Ans. Counting No of Nodes in Circular List Let list be a circular h

Circular doubly link list, what is circular doubly link list?write down the...

what is circular doubly link list?write down the algorithm for insertion of elements in circular doubly link list

Shortest path algorithms, A driver takes shortest possible route to attain ...

A driver takes shortest possible route to attain destination. The problem which we will discuss here is similar to this type of finding shortest route in any specific graph. The gr

Pseudocodes, how to write a pseudo code using Kramer''s rule

how to write a pseudo code using Kramer''s rule

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