(Potential massive search-space) Is this an exponential problem?

  • Thread starter htyj6g9jv1ev6
  • Start date
  • Tags
    Exponential
In summary, the conversation discusses a problem involving a journey of 256 steps where a person can either walk or hop, and the desire to compute a list of all possible combinations of actions. The question is raised about the potential for an exponential search-space and the number of possible combinations, which is determined to be 2^256. The conversation then discusses a possible algorithm for finding these combinations and the potential limitations. The question of why 256 steps and the need for a list is also brought up.
  • #1
htyj6g9jv1ev6
6
0
I'm writing a piece of software, however, my math skills are VERY rusty at the moment.

The problem is as follows:

  1. There is a journey consisting of 256 steps
  2. The person, can either i) walk, or ii) hop
  3. The person can choose what to do at each step
  4. I want to compute a list of all possible journey

I'm wondering if my attempt is futile... As the search-space may be too huge if this problem is indeed exponential.

My specific question is, how many ways are there through this journey? How many combinations of "walk" and "hop"?

I'm hoping that I'm wrong and the answer is not 2^256 (or around that area...). Otherwise I will have to abandon my simplistic brute force algorithm :D

Thank you!
 
Mathematics news on Phys.org
  • #2
htyj6g9jv1ev6 said:
I'm writing a piece of software, however, my math skills are VERY rusty at the moment.

The problem is as follows:

  1. There is a journey consisting of 256 steps
  2. The person, can either i) walk, or ii) hop
  3. The person can choose what to do at each step
  4. I want to compute a list of all possible journey

I'm wondering if my attempt is futile... As the search-space may be too huge if this problem is indeed exponential.

My specific question is, how many ways are there through this journey? How many combinations of "walk" and "hop"?

I'm hoping that I'm wrong and the answer is not 2^256 (or around that area...). Otherwise I will have to abandon my simplistic brute force algorithm :D

Thank you!

The answer is simply 2^256.

Test it out for smaller steps sizes.

2^1 = 2: 0,1
2^2 = 4: 00,01,10,11
2^3 = 8: 000,001,010,011,100,101,110,111

0 corresponding to walk
1 corresponding to hop

If you want to write your algorithm, it's incredibly easy. Just count from 0 to 2^256-1 writing out the number in 256 digit binary at each iteration. You'll need storage for 256 bits of precision, so you're not going to be able to rely on the built-in types, but you can handle this easily with nested loops. For 32-bit precision, you'll need 8 nested loops, then just write out the counters in 32-bit binary, in order.

The cool thing about this is that the order that the paths come out in, means that the early ones are valid for smaller step sizes too, so you can see where your computer stops making progress.

Was there a particular reason why you needed 256 steps?
Also is there a particular reason that you need a list of them?
 
Last edited:

FAQ: (Potential massive search-space) Is this an exponential problem?

What is an exponential problem?

An exponential problem is a problem in which the size of the search space grows exponentially as the size of the input increases. This means that as the input increases, the number of possible solutions also grows exponentially, making it increasingly difficult to find the optimal solution.

How do I know if a problem is exponential?

One way to determine if a problem is exponential is to look at the rate at which the search space grows. If the search space grows exponentially, then the problem is likely exponential. Additionally, if the problem involves repeated or recursive operations, it may also be an exponential problem.

Why are exponential problems difficult to solve?

Exponential problems are difficult to solve because the size of the search space grows at an exponential rate. This means that as the input size increases, the number of possible solutions also increases exponentially, making it difficult to find the optimal solution in a timely manner.

Can exponential problems be solved?

Yes, exponential problems can be solved, but they may require significant time and resources. In some cases, specialized algorithms or computing methods may be necessary to efficiently solve exponential problems. Additionally, finding an exact solution may not always be possible, so approximations or heuristics may be used.

How can I reduce the complexity of an exponential problem?

One way to reduce the complexity of an exponential problem is by finding patterns or structures within the search space that can be exploited to decrease the number of possible solutions. Additionally, using specialized algorithms or computing methods designed for exponential problems can also help reduce complexity.

Similar threads

Back
Top