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

learn more… | top users | synonyms

5
votes
2answers
78 views

Merge sort in C++ with iterators

I implemented merge sort with C++ and would like to get some feedback. ...
3
votes
2answers
77 views

Merge Sort Implementation: Space Usage

I have made a merge sort algorithm but am unsure of the 'Space Usage' of the algorithm. ...
10
votes
7answers
986 views

Merge sort for a List<T>

Is this merge sort following good coding standards? What are some improvements I can make to make it cleaner? ...
-1
votes
1answer
50 views

Merge sort optimization and improvement

How to optimize this merge sort code to make it run faster? And how to call merge_sort function without user input by declaring necessary array in the code? ...
2
votes
1answer
44 views

Is this an optimal implementation of merge sort?

I am taking an algorithm course and we are to implement merge sort that handles list of elements with even or odd number of elements and handles duplication, so I wrote this function: ...
4
votes
2answers
155 views

Sorting function that also works with containers having only forward iterators

I was playing around with some code trying to implement a sorting algorithm in C++ that also works with singly linked lists. Since the merge routine of mergesort only scans forward, implementing a ...
4
votes
3answers
245 views

Merge sort with raw C++ array

Merge function: ...
5
votes
2answers
207 views

Mergesort with std::vector

I made a mergesort implementation based on this code. Please review my C++ version. ...
3
votes
1answer
52 views

3-way merge sort in Java

All those numerous merge sorts split the range in two halves. This is a modification that splits each range into 3 subranges. My demo suggests that 3-way merge sort is pretty efficient on large ...
3
votes
3answers
320 views
2
votes
1answer
59 views

Natural merge sort in Java - follow-up

See the previous iteration: Natural merge sort in Java Arrays.java ...
2
votes
1answer
99 views

Natural merge sort in Java

Natural merge sort is a modification of merge sort that sacrifices O(N) to actually build a list of "runs" that may be defined as monotonically increasing or strictly decreasing contiguous ...
6
votes
2answers
184 views

Merge sort using sentinels

This is my implementation of recursive merge sort, using sentinels: ...
3
votes
1answer
73 views

Mergesort and validation

I have written an implementation of a Mergesort in Python3. An Ideone with the implementation is available. Any suggestions for improvement or any criticisms? ...
3
votes
2answers
97 views

Merge sort in Python

I've written a implementation of a merge sort in Python. It seems correct and I have tested it with this: ...
6
votes
2answers
179 views

Merge Sorting Lists

I'm fairly new to Java, arriving in the "future" from C and returning to type safety from Python. I'm looking for your suggestions to improve this code in the following areas: Correctness - are ...
4
votes
1answer
148 views

Merge sort in Golang

I am just starting out with golang. I implemented the merge sort algorithm just to practice. Any suggestions or criticisms regarding the coding style? ...
4
votes
2answers
90 views

External bottom up merge sort too slow

My external sort function works but it is way too slow. I think the bottleneck is the merge function. How can I make it faster. Is there a better merge function I can use for merging into a file using ...
3
votes
3answers
285 views

Merge Sort - Efficiency

I've written this Java code to implement Merge Sort. ...
3
votes
2answers
270 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 ...
5
votes
3answers
349 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
154 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
324 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
208 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
111 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
112 views
0
votes
0answers
51 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
166 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
1k 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
137 views

Algorithm for finding inversions in Merge Sort

Please help in code reviews for readability, optimizing it, functionality etc. ...
2
votes
2answers
158 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
308 views

Count array inversions merge sort

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

Merge Sorting in Python

This my implementation of the Merge Sorting Algorithm: ...
2
votes
2answers
221 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
6k 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
119 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
63 views

MergeSort w/ Custom Functions

Please review my implementation of mergesort: ...
2
votes
3answers
457 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
187 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
67 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
296 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
245 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
112 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
240 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
470 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
217 views
6
votes
3answers
6k 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
1k 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
135 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
217 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 ...