hzesen1221 / CS371P-OOP-Collatz

0 stars 0 forks source link

Addition 7: Using stack to cache. [ABANDONED] #17

Open hzesen1221 opened 12 years ago

hzesen1221 commented 12 years ago

Idea: when evaluating the cycle length of a particular number, push each results into a stack, the size of the stack (n) will then become the cycle length.

then, pop each number out, which has cycle length from 1 all the way to n.

hzesen1221 commented 12 years ago

analysis: this approach needs twice as many steps as the simplest version, and it does not work well in the recursive approach, therefore, abandoned.