retagged by
1,189 views
1 votes
1 votes
given an unsorted array with n distinct elements  with a property that  every element can be atmost k distance from its original position . what is the worst case time complexity  to get the sorted array.

ans O(n log k)

how .....
retagged by

1 Answer

1 votes
1 votes

1.using heap sort..take first k+1 element and make min heap O(k)...and delete min....and take one element from remaining n-k and insert in to heap-O((n-k)logk) again delete min...and so on...

Related questions

0 votes
0 votes
1 answer
1
raja11sep asked Jan 15, 2022
874 views
Can anyone explain each option, for every option if it is true then why? If false then why? (Please don’t comment like answer is A,B etc) Please help
2 votes
2 votes
1 answer
2
0 votes
0 votes
1 answer
3
0 votes
0 votes
3 answers
4