Back to course home
0% completed
Vote For New Content
Why would time complexity be O(n+n) instead of maybe something like O(n*n). [1,2...
Salah Osman
Feb 24, 2023
Why would time complexity be O(n+n) instead of maybe something like O(n*n). [1,2,3...infinity], s = infinity. While loop would have to run in the worst case infinity times with each process?
0
0
Comments
Comments
Design Gurus3 years ago
There are many ways to see this.
Let's see how many times both loops will run.
The outer 'For' loop can run a max of 'n' times.
Do you think the 'While' loop will run a max of 'S' times?
Actually its not.
Even the ‘while’ loop doesn’t run once for each iteration of...