We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This question is closer to being a version of quicksort than it is to being a version of merge sort. That being said, I do agree that the question is very poor as there is no reason that the partitions need to maintain their relative ordering. Doing so does NOT require additional space as OP states, but it does make it less efficient by a factor of a constant (you can keep the first half sorted, but have to reverse the second half).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Quicksort 2 - Sorting
You are viewing a single comment's thread. Return to all comments →
This question is closer to being a version of quicksort than it is to being a version of merge sort. That being said, I do agree that the question is very poor as there is no reason that the partitions need to maintain their relative ordering. Doing so does NOT require additional space as OP states, but it does make it less efficient by a factor of a constant (you can keep the first half sorted, but have to reverse the second half).