This is slightly confusing to me. What should be my approach of solving a given problem when the constraint is as follows:
1) Without using extra space: For e.g.: If I want to sort a given array, I have few ways of doing it. Bubble sort, which keeps on swapping ( just loops, no recursion). I believe this is said to be without using extra space. What is the case if I use a recursion to sort the elements. Is it the same as "without using extra space", or the stack used is counted in the Space complexity of the algorithm?
2) In O(1) space: What is the meaning of O(1) space? Does it mean constant space. Now if it is constant space then please comment on the following cases:
a) If I am swapping in bubble sort with the help of the third variable. Isn't it an extra space and it will not depend on the size of input so it is in constant space.
b) Moreover if I am using count sort being applied on natural numbers, where it doesn't really require the amount of space proportional to the total numbers, do we consider it to be in constant space O(1).
Please explain the difference if any. Thanks