Sorted list using binary search technique, Data Structure & Algorithms

Assignment Help:

Write an algorithm for searching a key from a sorted list using binary search technique

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:- Sorted list using binary search technique

Example of binary search, Let us assume a file of 5 records that means n = ...

Let us assume a file of 5 records that means n = 5 And k is a sorted array of keys of those 5 records. Let key = 55, low = 0, high = 4 Iteration 1: mid = (0+4)/2 = 2

Algorithms and flowcharts, write an algorithm and draw a flowchart to calcu...

write an algorithm and draw a flowchart to calculate the perimeter and area of a circle

Primitive data structure, Primitive Data Structure These are the basic ...

Primitive Data Structure These are the basic structure and are directly operated upon by the machine instructions. These in general have dissimilar representations on different

State in brief about assertion, State  in brief about assertion Asser...

State  in brief about assertion Assertion: A statement which should be true at a designated point in a program.

Binary search tree, write an algorithm to delete an element x from binary...

write an algorithm to delete an element x from binary search with time complex

Linear node is given by means of pointer, A linear collection of data eleme...

A linear collection of data elements where the linear node is given by means of pointer is known as Linked list

Siso-4bit register, explain working of siso-register to store 1011 and show...

explain working of siso-register to store 1011 and show timing diagram &table

Present the algorithm of binary search. , B i n a ry Search Alg...

B i n a ry 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.

Algorithsm, What are the properties of an algorithsm?

What are the properties of an algorithsm?

Time complexity, The  total  of  time  needed  by  an algorithm to run to i...

The  total  of  time  needed  by  an algorithm to run to its completion is termed as time complexity. The asymptotic running time of an algorithm is given in terms of functions. Th

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