For example, if you implement an algorithm that takes and utilizes strings, If the string is up to 1000, If you allocate 1000 spaces as char arrays in advance as global variables and continue to reuse them, I wonder if the spatial complexity can be called O(1)
It's easy to find a conceptual explanation of time complexity It's hard to find a detailed description of the spatial complexity If you have any good comments, please let me know
space-complexity
I don't know, but I just typed space complexity for array.
If you make an array that is always N in length (by blade coding), [space complexity] is O(1). Because, no matter how you run an algorithm, the space you create is always the same.
[Space complexity] O(f(n)) if the N value increases according to the input. where f(n) is the relationship function between the size n of the input and the size N of the array.
I hope this translation helps.
© 2024 OneMinuteCode. All rights reserved.