10.09.2013 Views

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

LECTURE NOTES OF ADVANCED DATA STRUCTURE (MT-CSE 110)<br />

This searching technique searches the given item in minimum possible no. of<br />

comparisons. To do the binary search first we have to sort the given array<br />

elements.<br />

IMPEMENTATION OF BINARY SEARCH<br />

Binary search operation is divided into 3 cases<br />

Case1: if a [item] a [mid]<br />

Then, big=mid+1<br />

ALGORITHIM<br />

The algorithm for binary search is given below‐<br />

Algo: Binary search(A,N,X)<br />

A=name of array<br />

N=number of element<br />

X=element to be searched in array A<br />

If the search is successful this algorithm finds the location or position of x in<br />

the array otherwise the value 0 is return.<br />

<strong>1.</strong> [Initialize variables]<br />

First=1, last=N<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

Assist Prof., CSE, H.C.T.M (Kaithal) Page ‐ 155 ‐

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!