Back to course home
0% completed
Vote For New Content
Wouldn't the time complexity be O(N + logN) instead? Because the sorting is done...
eric
Feb 10, 2022
Wouldn't the time complexity be O(N + logN) instead? Because the sorting is done outside the loop which incurs a O(logN) time, and afterward we're just looping through each interval which is O(N). Since the sorting is not done within the loop, it would be an addition instead of multiplication wouldn't it?
0
0
Comments
Comments
Design Gurus4 years ago
Not sure if we understood your question correctly.
Sorting takes O(N * logN) which defines the overall time complexity of the algorithm.
Later we iterate the array once; this means overall time complexity will be:
O( N * log N )+ N)) => O(N * logN) as 'N < N * logN...
On this page