Thread: high or low !

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    5

    Question 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. #2
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    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. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    5

    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. #4
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ace high and low in card game
    By ninety3gd in forum C Programming
    Replies: 3
    Last Post: 05-10-2009, 08:16 PM
  2. C/C++, low or high level?
    By Sentral in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-23-2007, 11:43 PM
  3. what is the significance of low order and high order bits
    By Shadow12345 in forum Windows Programming
    Replies: 1
    Last Post: 11-16-2002, 11:46 AM
  4. low value, high value and increment
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 11-25-2001, 09:01 AM