Time complexity is a measure of how the running time of an algorithm increases as the input size increases. It indicates the number of steps the algorithm takes based on the input. Since every computer takes a different time to perform computation, we need a standard mechanism to measure the speed of computation, which is given by time complexity. It measures how fast the number of operations increases as inputs get bigger.
What is space complexity?
Space complexity is the amount of memory or space the algorithm takes to run as a function of input size. It includes:
fixed parts -> which are the constants, program instructions, and variables
variable part -> which includes memory of data structures used, stacks, function calls, and temporary variables.