in Algorithms edited by
739 views
1 vote
1 vote

What is the worst case time complexity to count pairs of numbers with difference ‘k’ from an input array of ‘n’ numbers?

a) O(logn)

b) O(nlogn)

c) O(n^2)

d) O(n^2logn)

in Algorithms edited by
by
739 views

4 Comments

edited by
Use merge sort for sorting. In worst case O(nlogn) & O(nlogn) to find x-y = k.
0
0
But what is the need to sort if Worst Case Time complexity is asked?
0
0
Worst case of best algo?
0
0

Please log in or register to answer this question.

Related questions