0

Find the time complexity of the findNode() method from this code.

Time complexity of an algorithm https://code.sololearn.com/cjmldlLPUlj5/?ref=app

19th Jan 2019, 5:50 AM
Sailesh Dahal
Sailesh Dahal - avatar
1 Answer
+ 1
It's O(n). The function is more complicated than necessary so may check each node up to 2 times. So it could be twice as fast in the worst case, but would still be O(n).
19th Jan 2019, 9:25 AM
Jared Bird
Jared Bird - avatar