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

learn more… | top users | synonyms

3
votes
3answers
137 views

Merge Sort - Efficiency

I've written this Java code to implement Merge Sort. ...
3
votes
2answers
64 views

Merge sorting linked lists

This works as expected and I want to get this code reviewed so that I can improve my coding ability. I am concerned about readability and the quality of the code ...
4
votes
3answers
114 views

Merge Sort Implementation in Java (that seems slow…)

I decided to write my own implementation of merge sort. Here is the code: ...
9
votes
1answer
69 views

File-based fixed-record merge sort

A problem posted here to Code Review prompted me to experiment with a general-purpose merge-sort algorithm for any fixed-length record data. External / File-based mergesort I answered that question, ...
7
votes
2answers
58 views

External / File-based mergesort

I've implemented an external mergesort to sort a file consisting of Java int primitives, however it is horribly slow (fortunately it does at least work). Very little happens in the sort method: it ...
7
votes
2answers
91 views

Merge sort in JavaScript

I implemented this merge sort in JS and noticed that for random integer numbers it's a lot faster than the build in sort functions of all the browsers I tested (Chrome, FF, IE). Does anyone have an ...
5
votes
3answers
73 views

Merge Sort implementation in Java

Can you check my merge sort implementation? From all of my testing it seems like it works, but I just wanted to make sure I am doing it as good as possible, and it couldn't be optimized any further. ...
2
votes
3answers
83 views
0
votes
0answers
45 views

Is my implementation of a merge sort correct?

I tried to get into programming several times but never did and never got very far past "Hello, World.", until recently when I found and read (most of, still don't get parts of it) "The Little ...
3
votes
2answers
77 views

Implementation of merge sort and bubble sort

I'm new to Go and looking for a review of my merge sort and bubble sort implementations. What can be done better? Can my code be cleaner/clearer? ...
4
votes
1answer
117 views

Counting inversions

Inversion Count for an array indicates – how far (or close) the array is from being sorted. If array is already sorted then inversion count is 0. If array is sorted in reverse order that inversion ...
6
votes
1answer
71 views

Algorithm for finding inversions in Merge Sort

Please help in code reviews for readability, optimizing it, functionality etc. ...
2
votes
2answers
89 views

Merge Sort Java Implementation

Can someone check my Merge Sort implementation on Java? Is it good/bad and can it be improved further? ...
4
votes
1answer
69 views

Count array inversions merge sort

How does it look? Comments, code correctness, etc. ...
3
votes
3answers
102 views

Merge Sorting in Python

This my implementation of the Merge Sorting Algorithm: ...
1
vote
2answers
99 views

Merge sort algorithm implementation using C++ (redux)

This is a follow up question to the one I asked a couple of days ago. I reviewed the suggestions & did some research (specifically, read relevant info on CLRS). The new version is 3 times ...
6
votes
2answers
2k views

Merge sort algorithm implementation using C++

I'm trying to learn proper C++ and algorithms at the same time. I particularly feel weird about my iterators usage in merge function. Is this a good way to handle ...
3
votes
2answers
71 views

How might we make this Python Merge Sort implementation more Pythonic?

I've implemented a (version of) Merge Sort algorithm in Python. My goal here is two-fold: Improve understanding of Merge Sort and recursion in a language agnostic way. Improve understanding of ...
2
votes
2answers
51 views

MergeSort w/ Custom Functions

Please review my implementation of mergesort: ...
2
votes
3answers
98 views

Implementing the merge sort with only arrays, out of place

This has been asked a few times here, but I was wondering what I could do to improve the efficiency and readability of my code. My programming skill has gotten rusty, so I would like to elicit all ...
2
votes
1answer
118 views

Merge Sort optimization

I was looking at other people code and I realized that mine is not so neat after all. In this version, I included a base case for the merge part (when there is only 2 elements to merge, just sort it ...
3
votes
1answer
60 views

Is there a better way to return values with merge sort?

I have been attempting to learn Scala lately and so have produced a couple of different sorting algorithms to build up my basics. I think I have been lucky with the methods returning exactly what I ...
5
votes
2answers
157 views

Racing Java Arrays.sort with NON recursive Merge Sort implementation

I found a bit better implementation for Java Arrays.sort(int[]). To make this code review more simple I divide this questions to several parts. The goal of this ...
6
votes
2answers
114 views

Generic Multiway Merge

Recently I had a problem (not in C++) that required merging a number of sorted lists of values. This is effectively the generalised case of merging together two sorted lists. However, instead of ...
6
votes
1answer
96 views

Merge sort could work 10 times faster

I am implementing merge sort in Java and I have a performance problem in this method: ...
7
votes
4answers
203 views

MergeSort performance

Do you see any inefficient parts with the following code? On internet I see 30 ms for 100.000 integers but I can sort 100.000 integers in 300ms. The data is random. I am using late 2013 macbook pro so ...
3
votes
1answer
193 views

Is there anything to improve in this MergeSort code in Java?

I have written an implementation of the merge sort algorithm in Java. Here is the MergeSort class that I created. ...
5
votes
1answer
159 views
6
votes
3answers
3k views

Merge Sort Algorithm in Python

I'm implementing basic sorting algorithms to learn them, and coding, better. Criticisms and possible optimizations welcome. ...
7
votes
2answers
433 views

Is this non-recursive mergesort efficient and a good way to simulate the recursive version?

My teacher assigned us to do the recursive version of mergesort, yet I heard that the non-recursive version (bottom up) is a bit tougher, so I decided to this one as well. My main concerns are: ...
4
votes
1answer
96 views

Is this an efficient merge sort implementation with regards to average time complexity in Big-O notation?

Is my below merge sort implementation in O(n log n)? I am trying to implement a solution to find k-th largest element in a given integer list with duplicates with O(N*log(N)) average time complexity ...
1
vote
1answer
149 views

Merge Sort Program

I have written the following program to implement merge sort in F#. Can you please review this and let me know how can I write this in the most functional way (also most efficient and concise)? In ...
4
votes
2answers
228 views

Merge two sorted arrays together

Please review my answer for this interview question: ...
0
votes
1answer
157 views

MergeSort implementation with java.util.List passed as argument, not returned

I'm working on an implementation of MergeSort which sorts a List given as an argument. As follows ...
3
votes
1answer
8k views

Merge Sort in C++

I've written this code for a merge sort, which is meant to implement the pseudo-code from Cormen's Introduction to Algorithms: ...
2
votes
2answers
781 views

Merge Sort Implementation

Any reviews/ways to speed up/general improvements for my Merge Sort? Maybe something to simplify it or add more to it? ...
1
vote
1answer
2k views

Merge sort with a linked list

I'd like this code reviewed. ...
3
votes
1answer
126 views

Recursive Implementation of merge sort

Information about my code: I am following this MIT OCW algorithms course. The first lecture described insertion sort and merge sort. I implemented merge sort in C. The algorithm is structured as a ...
6
votes
2answers
302 views

Merge Sort: exercise

I've decided to learn Haskell by following the current Coursera algorithms course using Haskell to implement the algorithms discussed. First up is merge sort, which I've implemented as shown here. ...
1
vote
1answer
204 views

Debug merge sort and validate comparison counters

I am posting the code for my merge sort to see if I can get folks offer suggestions as to where to make comparisons or if I am making the correctly already. I will post my heap sort and quick sorts ...
3
votes
2answers
363 views
6
votes
3answers
923 views

Merge sort in Scala

I've implemented merge sort in Scala: ...
4
votes
2answers
377 views

ANSI C Mergesort - Pedantic criticism please

This is a mergesort implementation I wrote, 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 i'm sure), but ...
8
votes
4answers
782 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
312 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? ...
1
vote
1answer
443 views

Am I doing this right? Merging 2 ordered source arrays into one destination array

My instructions were: Add a merge() method to the OrdArray class in the orderedArray.java program (Listing 2.4) so that you can merge two ordered source arrays into an ordered destination ...
5
votes
2answers
3k views
5
votes
0answers
586 views

Merge sort in Scheme

...
1
vote
0answers
170 views

F# mergesort code : where to improve

I would appreciate some quick comments on this basic mergesort code. Am I missing a big block in the langage? ...
4
votes
2answers
1k 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 ...