If the array is declared static in the algorithm problem, is the spatial complexity O(1)?

Asked 2 years ago, Updated 2 years ago, 118 views

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

2022-09-20 22:32

1 Answers

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.


2022-09-20 22:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.