2

Disclaimer: there are many questions about it, but I didn't find any with requirement of constant memory.

Hamming numbers is a numbers $2^i 3^j 5^k$, where $i$, $j$, $k$ are natural numbers.

Is there a possibility to generate Nth Hamming number with $O(N)$ time and $O(1)$ (constant) memory? Under generate I mean exactly the generator, i.e. you can only output the result and not read the previously generated numbers (in that case memory will be not constant). But you can save some constant number of them.

I see only best algorithm with constant memory is not better than $O(N log N)$, for example, based on priority queue.

But is there mathematical proof that it is impossible to construct an algorithm in $O(N)$ time and $O(1)$ memory?

vladon
  • 121
  • 3

0 Answers0