A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Questions tagged [mergesort]

Merge sort is an O(n log n) comparison-based sorting algorithm.

Filter by
Sorted by
Tagged with
3
votes
2answers
1k views

Mergesort implementation in Clojure

...
8
votes
1answer
4k views

Merge sort in Scala

I've implemented merge sort in Scala: ...
4
votes
3answers
220 views

Mergesort with an inversion counter

I'm new to Lisp and I'm yet to wrap my head around the lisp way of writing programs. Any comments regarding approach, style, missed opportunities appreciated: In particular, please advice if I build ...
5
votes
2answers
1k views

ANSI C Mergesort

This is a working mergesort implementation I wrote as I'm trying to get back into C. I am not so much interested in feedback on the optimality of the algorithm (as I could read up countless articles ...
8
votes
4answers
3k views

Given two sorted arrays, add the elements of the second array into the first

In Cracking the Coding Interview by Gayle Laakmann McDowell, there's a question that asks you to write code for the following: Given two sorted arrays, A and B. Write a method merging the elements ...
7
votes
3answers
757 views

Is this attempt at a merge sort correct?

I am trying to write a merge sort algorithm. I can't tell if this is actually a canonical merge sort. If I knew how to calculate the runtime I would give that a go. Does anyone have any pointers? <...
8
votes
1answer
17k views

Inversion count using merge sort

...
26
votes
1answer
2k views

Merge sort in Scheme

...
4
votes
1answer
332 views

Three implementations of mergesort in F#

I would appreciate some quick comments on this basic mergesort code. Am I missing a big block in the langage? First solution ...
4
votes
2answers
2k views

Merge sort on an Integer class

This is a specific case in merge sort. I'm trying to do a merge sort on an array that's created using the Java Integer class. My implementation is slow and ...
14
votes
2answers
8k views

Parallel Merge Sort

Parallism is achieved by using a simple call to tbb::parallel_invoke(). However I can't break a speedup factor of x2 (after ~3-4 parallel HW threads), although 8 ...
7
votes
1answer
721 views

Merge sort and selection sort comparison taking too long

I have this python code that compares merge sort and selection sort, but it is taking "forever." ...