Merge Sort Algorithm

Sep 5, 2018 at 4:44am
https://www.spoj.com/problems/PAIRS1/
Can we do this problem using merge sort algorithm. I have done this using binary search.

Last edited on Sep 5, 2018 at 4:45am
Sep 5, 2018 at 7:24am
Why merge sort?
Why not std::sort?
Sep 5, 2018 at 8:05am
You have used binary search. Binary search operates on sorted sequence. Therefore, you had a sorted sequence already. Now you ask about sorting?

There are multiple algorithms for sorting. They all have their strengths and weaknesses. Can you tell which suite for your problem and why?
Sep 5, 2018 at 1:09pm
In my experience, the only time you really NEED a sorted collection is when you must output the data in sorted order. For this problem I can think of a solution that runs in O(N) time and doesn't use sorting.
Sep 5, 2018 at 5:38pm
I mean to say that in merge sort algorithm we make a merge tree we find the answer while sorting. So can we do this problem like that.
And thank you for giving your time :)
Topic archived. No new replies allowed.