enrique wrote:

i m in touch with c from last 1yr now just started data stucture in c

and i have a problem

in linear search and binary search if any one could explain with one

example each

thanks in advance

I believe this is OT for this forum, but heres an example anyway:

a list of unsorted numbers:

8 4 9 5 7 6 1 2 3

We want to search for 7. Linear search, start at beginning and go

through each number until you hit 5. i.e. 8->4->9->5->7 done.

Binary search, sort first.

1 2 3 4 5 6 7 8 9

Look at middle point: 5, this is less than 7 so it can't be in the

bottom half so chop it out and you're left with

6 7 8 9

Look at middle point (say 8 for now) this is greater than 7 so can't be

in top half. Left with

6 7

Look at middle point (7) done.