Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 help RE: Binary searches
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
drewst18




PostPosted: Tue Nov 30, 2004 1:21 pm   Post subject: help RE: Binary searches

We have a program to write, using binary search. I have no idea how to do this(nobody in the class does). Can someone help by teaching us or doing a quick search
Sponsor
Sponsor
Sponsor
sponsor
bugzpodder




PostPosted: Tue Nov 30, 2004 1:27 pm   Post subject: (No subject)

Definition: Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.
wtd




PostPosted: Tue Nov 30, 2004 3:18 pm   Post subject: (No subject)

bugzpodder wrote:
Definition: Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.


Or in other words, the old game of guess the number. Let's say I tell you to guess a number between 1 and 10. You get three guesses.

The answer: 3

First guess: 5
Too high!
Next Guess: 2
Too low!
Final guess: 3 (the only other option is 4)
Correct!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: