Algorithm Analysis: Time and Space Complexity
Classified in Computers
Written on in
English with a size of 4.5 KB
Space Complexity
- Analysis of the space complexity of an algorithm or program is the amount of memory it needs to run to completion.
- The space needed by a program consists of the following components:
- Fixed space requirements: Independent of the number and size of the program's input and output. It includes:
- Instruction Space (Space needed to store the code)
- Space for simple variables
- Space for constants
- Variable space requirements: This component consists of:
- Space needed by structured variables whose size depends on the particular instance I of the problem being solved
- Space required when a function uses recursion
Total Space Complexity
S(P) of a program is:
S(P) = C + Sp(I)
Here Sp(I) is the variable space requirements of program P working on an instance... Continue reading "Algorithm Analysis: Time and Space Complexity" »