data stucture using c

E

enrique

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
 
C

chris.fairles

enrique said:
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.
 
F

Frederick Gotham

Ian Collins posted:
Inappropriately harsh.

This isn't some one posting in gobbledygook speak, it is some one doing
their best in a second language.


If anything, I thought it might get across to the OP that maybe they should
try improve the quality of their writing.

(English not being the OP's mother tongue doesn't quite explain the lack of
punctuation -- unless their mother tongue is written in a different script I
suppose.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top