Skip to content

Instantly share code, notes, and snippets.

@sherman
Last active September 25, 2015 05:29
Show Gist options
  • Save sherman/5e5a75ead1a533a622e6 to your computer and use it in GitHub Desktop.
Save sherman/5e5a75ead1a533a622e6 to your computer and use it in GitHub Desktop.
public static long[] sortIterative(long[] data) {
Queue<long[]> q = new LinkedList<>();
for (long elt : data) {
q.add(new long[]{elt});
}
while (q.size() > 1) {
long[] res = mergeSorted(q.poll(), q.poll());
q.add(res);
}
return q.poll();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment