4 ms·
> In fact, the above code is a perfect example of a time-memory tradeoff Not as much since the program will take increasingly more time to run as the input num
by tcgv 3y ago
> In fact, the above code is a perfect example of a time-memory tradeoff
Not as much since the program will take increasingly more time to run as the input number gets higher. Checking if a 'small' number is even or odd will be pretty fast. Checking a 'large' number will be slow since it will go through all 'IFs' until it reaches the result.
It's like O(M/2) average time complexity where 'M' is a constant, the program memory size (number of 'IFs' stored).
- vitiral 3y agoI took it as a joke. The tradeoff is the programmer's time and memory, not the computer's