What Is The Space Complexity when There Are Two Variables in a Program?

Question
You have a program with two (or three) variables, but no other data structures. What is the space complexity?

Answer
O(1). An algorithm, as long as the number of variables is fixed, can have 1,000 variables and be said to have O(1) space complexity. The source is here:

https://stackoverflow.com/questions/43260889/what-is-o1-space-complexity

Leave a comment

Your email address will not be published. Required fields are marked *