Algorithms and Data Structures · Junior · Question 11 of 75

What does O(1) extra space mean for an algorithm?

Explanation

O(1) space means a fixed amount of additional memory regardless of n: a few counters or pointers. Reversing an array in place with two indices is O(1) space; copying it into a new array is O(n).

Further reading

Problem with a question

Algorithms and Data Structures · Junior · question 11

Test yourself

Take the Algorithms and Data Structures · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz