0
Complexity
what are different space and time complexities
3 Antworten
+ 8
As I understand the time is that required to take amount of input while space is the amount of memory required that amount of input.
+ 5
These two concepts are used to measure an algorithm.
Space refers to the memory space required while time refers to the time taken or generally no. of interation in Big-O-notation.
Most of the time it's about the trade-off between the two.
For example if we want to determine the nth perfect square we can either:-
[ TIME ]
☑ Write a loop which iterate n times to compute the result
▫More runtime, less space required
or
[ SPACE ]
☑ Initiate an array to store an arbitrary large number of perfect squares beforehand and just use its index to determine the result
▫ More space, less runtime required
+ 3
Well according to my understanding, time is something like you check a particular algorithm or code that how much time it took to get executed.
And space is checked like how much memory will the program take during its execution.
Correct me if I am wrong :)