Back to Developer Roadmap

Time vs Space Complexity

src/data/roadmaps/datastructures-and-algorithms/content/time-vs-space-complexity@unaYmPzK761Eh_iZMLeRC.md

4.01.1 KB
Original Source

Time vs Space Complexity

In the context of algorithmic complexity, "time" refers to the amount of computational time that the algorithm takes to execute, while "space" refers to the amount of memory that the algorithm needs to complete its operation. The time complexity of an algorithm quantifies the amount of time taken by an algorithm to run, as a function of the size of the input to the program. The space complexity of an algorithm quantifies the amount of space or memory taken by an algorithm to run, as a function of the size of the input to the program. It's important to note that time and space are often at odds with each other; optimizing an algorithm to be quicker often requires taking up more memory, and decreasing memory usage can often make the algorithm slower. This is known as the space-time tradeoff.

Visit the following resources to learn more: