What does O(1) space mean? I understand that O(n) steps is like the order of magnitude of calculations an algorithm/program makes, but don’t know what the O(n) space is.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
O(1) space means that the memory required by the algorithm is constant, i.e. does not depend on the size of the input.
O(n) space means that the memory required by the algorithm has (in the worst case) the same order of magnitude as the size of the input.
Edit:
Adding two examples: