Which of the following best describes space complexity of an algorithm?

2025

Which of the following best describes space complexity of an algorithm?

  1. A.

    The disk space occupied by the source code of the algorithm.

  2. B.

    The number of CPU cycles used during execution.

  3. C.

    The total amount of memory required by the algorithm, including input, variables, and function call overhead.

  4. D.

    The amount of time required to execute the algorithm.

Attempted by 155 students.

Show answer & explanation

Correct answer: C

Space complexity measures the total peak memory (RAM) an algorithm needs to run to completion as a function of the input size n. This includes:

  • Input Space: The memory needed to store the input data.

  • Auxiliary Space: Extra memory used for temporary variables, dynamic allocations, and the call stack overhead (which tracks active stack frames during recursive or nested function calls).

Explore the full course: Rssb Senior Computer Instructor