I'm a bit lost on Auxiliary Space Complexities.
In the lecture that I am taking the instructor states that strings have a space complexity O(n), since the length of the string(n) will vary. But primitives such as numbers, booleans, undefined, etc have a constant space complexity O(1).
I'm confused because if the space of strings differ by its length, would that not be the same with numbers as well? Since they also will have different "lengths"?
I do understand how booleans and undefined is O(1), I mean true/false, undefined and null are length-independent instances.
If anyone can clarify this for me, I would appreciate it.
In real world number size is indeed unlimited, however here it's about numerical primitives. Each primitive by definition requires a fixed number of storage units (and that's the reason why it can hold only a limited range of values). Unlike numerical primitives, size of a string is theoretically unlimited and it occupies storage corresponding to input size (i.e., characters which constitute the string).