# Thread: high or low !

1. ## high or low !

Hi
Maybe this question is redundant and I apologise if it is ,cause I tried searching I was not able to find the exact answer .

If I want to find out if the user-typed value is too low or too high ,how I can do it ? Like I have the user enter 78 ,but the value that he shd have typed is 80 .Then I cant just say too low .I will have to say something like "nearer to the actual value " .I have an hint thats says use Binary search .But I dont understand how it works ..
Can anybody enlighten me on this?

Thanks for your time and patience .

2. First you would compare the user's input to the original number and specify whether it's lower or higher. Then you can take the absolute value of the difference and specify the relative difference between the numbers. Say for example it's +- 5 within the number then you can comment that the user is getting real close.

I'm not sure what a binary search would have to do with this problem. Unless you're maybe inserting the user's guesses into a tree and depending on how where it traverses down the tree, you can give feedback based on the user's previous input.

3. ## clarification

Hi
You are right .I think the use of Binary search is necessary because the next response depends on the users' previous responses .

There are 3 responses -
>Correct
>Too low .Try again
>Too high .Try again .

it says " If the player's guess is incorrect ,your program should loop until the player finally gets the number right .Your program shd keep telling the player Too high or Too low to help the player "zero in" on the correct answer.

Can you give me a good example/link etc for this ?

Thanks for your time and patience .

4. Here's a brief intro:
http://oopweb.com/Algorithms/Documen...iles/s_bin.htm

There's plenty of resources out there that'll give you example code for binary trees.