You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should make sure that we point out that array assignment in JavaScript is not O(1). Instead, we can only say that it's O(n) where n is the index.
const a = [];
a[1000000] = 0;
This does not necessarily run in constant time. Our explanation should be consistent with the fundamental property that time complexity is always greater or equal than space complexity, under the assumption that the input data is included in the space complexity and the time it takes to construct the input data is included in the time complexity.
The text was updated successfully, but these errors were encountered:
martin-henz
changed the title
Documenation: Complexity of array assignment in Source §3,4
Documentation: Complexity of array assignment in Source §3,4
Mar 30, 2024
We should make sure that we point out that array assignment in JavaScript is not O(1). Instead, we can only say that it's O(n) where n is the index.
This does not necessarily run in constant time. Our explanation should be consistent with the fundamental property that time complexity is always greater or equal than space complexity, under the assumption that the input data is included in the space complexity and the time it takes to construct the input data is included in the time complexity.
The text was updated successfully, but these errors were encountered: