Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7722467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:10:57+00:00 2026-06-01T04:10:57+00:00

Here’s something I’ve been thinking about: suppose you have a number, x, that can

  • 0

Here’s something I’ve been thinking about: suppose you have a number, x, that can be infinitely large, and you have to find out what it is. All you know is if another number, y, is larger or smaller than x. What would be the fastest/best way to find x?

An evil adversary chooses a really large number somehow … say:

int x = 9^9^9^9^9^9^9^9^9^9^9^9^9^9^9

and provides isX, isBiggerThanX, and isSmallerThanx functions. Example code might look something like this:

int c = 2
int y = 2
while(true)
    if isX(y) return true
    if(isBiggerThanX(y)) fn()
    else y = y^c

where fn() is a function that, once a number y has been found (that’s bigger than x) does something to determine x (like divide the number in half and compare that, then repeat). The thing is, since x is arbitrarily large, it seems like a bad idea to me to use a constant to increase y.

This is just something that I’ve been wondering about for a while now, I’d like to hear what other people think

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:10:58+00:00Added an answer on June 1, 2026 at 4:10 am

    Use a binary search as in the usual “try to guess my number” game. But since there is no finite upper end point, we do a first phase to find a suitable one:

    • Initially set the upper end point arbitrarily (e.g. 1000000, though 1 or 1^100 would also work — given the infinite space to work in, all finite values are equally disproportionate).
    • Compare the mystery number X with the upper end point.
    • If it’s not big enough, double it, and try again.
    • Once the upper end point is bigger than the mystery number, proceed with a normal binary search.

    The first phase is itself similar to a binary search. The difference is that instead of halving the search space with each step, it’s doubling it! The cost for each phase is O(log X). A small improvement would be to set the lower end point at each doubling step: we know X is at least as high as the previous upper end point, so we can reuse it as the lower end point. The size of the search space still doubles at each step, but in the end it will be half as large as would have been. The cost of the binary search will be reduced by only 1 step, so its overall complexity remains the same.

    Some notes

    A couple of notes in response to other comments:

    It’s an interesting question, and computer science is not just about what can be done on physical machines. As long as the question can be defined properly, it’s worth asking and thinking about.

    The range of numbers is infinite, but any possible mystery number is finite. So the above method will eventually find it. Eventually is defined such as that, for any possible finite input, the algorithm will terminate within a finite number of steps. However since the input is unbounded, the number of steps is also unbounded (it’s just that, in every particular case, it will “eventually” terminate.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is another spoj problem that asks how to find the number of distinct
Here is the issue I am having: I have a large query that needs
Here is an excise: In certain graph problems, vertices have can have weights instead
I have a jquery bug and I've been looking for hours now, I can't
Here is my code (Say we have a single button on the page that
Here's my scenario - I have an SSIS job that depends on another prior
Here is my problem...I have a page that loads a list of clients and
Here is an excise Suppose we are given the minimum spanning tree T of
Here's the thing. I forgot which I installed. I have used cat /etc/lsb-release and
Here's the basic setup: I have a thin bar at the top of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.