Back to course home
0% completed
Vote For New Content
How is the complexity of brute force O(N*K)?N is the number of elements in input...
aj
Jun 5, 2022
How is the complexity of brute force O(N*K)? N is the number of elements in input array - which in the example is 9. But the outer loop doesn't run 9 times does it? It will only run from 0 to arr.length - K i.e 4 times.
2
0
Comments
Comments
A
aj 3 years ago
Its 5 times, typed wrong.
Design Gurus3 years ago
The time and space complexities are stated in asymptotic (Big-O) notations, they do not refer to the actual number of iterations; instead, they refer to the 'limiting behavior' of the function.
You are right that the outer loop runs for 'N-K' times, which means, the ti...
On this page