Questions tagged [mergesort]
For code that implements a merge sort or a significant part of it
296 questions
2
votes
1
answer
100
views
Multithreaded Merge Sort Using ForkJoin Framework
I've implemented a multithreaded merge sort using Java's ForkJoin framework, and I wanted to gather feedback on its correctness, efficiency, and scalability.
Here's my implementation:
...
1
vote
3
answers
134
views
another Merge Sort
I've tried to implement merge sort in c with varying degrees of success, one was correctly sorting the array but leaking memory, one was neither sorting the array and leaking memory.
The following was ...
1
vote
1
answer
129
views
Queue-mergesort: a mergesort that does optimal number of comparisons in the worst case in Java
Here is the code for queue-mergesort by Mordecai J. Golin and Robert Sedgewick:
com.github.coderodde.util.QueueMergesort.java:
...
2
votes
1
answer
86
views
Merge Sort with Minimum Sufficient Variables, Verbosity and better Space Complexity
The majority of merge sort implementations searched online are provided with unnecessary variables and code lines. Here is an attempt to reduce that. However, does passing back the subArray as return ...
3
votes
2
answers
269
views
C++ merge sort, logging, unit test, performance check
I wrote a merge sort implementation in C++ today in C++20 way.
...
9
votes
3
answers
1k
views
C++ merge sort implementation (looking for advice)
I am trying to practice C++, so I decided to implement canonical algorithms in C++ as a way to learn best practices and idioms of the language.
I started with merge sort. How could I improve this ...
1
vote
2
answers
193
views
Bottom-up merge sort
I think I programmed a bottom-up merge sort, but I'm a little sceptical that it will work under any data set. By now, I've tested it with many random arrays of massive lengths, and it seems to work; ...
1
vote
2
answers
126
views
Comparison of 2 different ways of writing Merge Sort Algorithm
I have recently learned Merge Sort algorithm in C++ with 2 ways of writing it.
1st Way:
...
2
votes
3
answers
620
views
Parallezing merge step and divide step in mergesort algorithm with OpenMP
We wrote a code that parallelizes the divide phase of the mergesort algorithm. I.e. every recursive call is assigned to a thread but our teacher was disappointed because he said we should also ...
5
votes
1
answer
119
views
Merge Sort implementation is messy
I am using this merge sort function to sort table rows by Date, Letter, and Number. It works, but it is super messy and hard for others to read.
The dates are being sorted in two formats YYYY-MM-DD ...
2
votes
2
answers
142
views
Merge Sort for Linked List Criticism in C
I previously implemented a Merge Sort for arrays, so after fixing up my code for the array-based merge sort I have now implemented a merge sort for a basic singly-linked list data structure which only ...
2
votes
3
answers
496
views
A Merge Sort implementation for efficiency
This is my version of mergesort.
...
4
votes
1
answer
3k
views
Hybrid Merge/Insertion sort algorithm
Explanation: Although merge sort runs in Ω(nlgn) and insertion sort runs in Ω(n^2), the constant factors in insertion sort can make it faster in implementation for small problem sizes. This sorting ...
3
votes
1
answer
158
views
Mergesort in python
My mergesort implementation currently takes a very long time, for a list with 1 million elements it takes over 130 seconds to get the list sorted.
Could someone kindly have a look at my code and ...
3
votes
2
answers
167
views
HybridSort of QuickSort and MergeSort
I'll try to publish a paper about the programming language I've made (ArithmeticExpressionCompiler, short AEC) in Osječki Matematički List and, in order to demonstrate its usability for implementing ...
5
votes
1
answer
124
views
How to merge two descending singly linkedlist into one ascending linkedlist using Recursion without any helper method?
Here is my solution:
I want to know if my solution fits the requirement 100%? Or if there is any better solution?
Constraint of the question:
must be singly linkedlist
must use recursion, and no ...
4
votes
1
answer
192
views
CLRS implementation (opportunity to sort subarray) of merge sort in golang
I'm reading "Introduction to Algorithms" by CLRS and I can't find an implementation of the pseudo code from the book in golang. By the original implementation I mean that we deal with extra parameters ...
2
votes
1
answer
70
views
Return union and complement of three sets
I would be especially happy to hear opinions about complement_union.
The rest of the code is just there to test the output.
...
2
votes
1
answer
411
views
Parallel MergeSort in C++
I've tried to implement parallel MergeSort in C++, that also tracks how many comparisons it's made and how many threads it uses:
...
4
votes
0
answers
307
views
Rust Iterative and Recursive Merge Sort Implementation
I'm in the process of learning both Rust and algorithms after primarily focusing on web development. As such I've had a go at implementing merge sort both iteratively and recursively.
I've looked for ...
6
votes
5
answers
515
views
Implemented command-line based merge-sort algorithm. How can I make the code efficient, robust, maintainable, secure?
This is follow up question regarding merge-sort implementation to the previous post.
Recently I have implemented a command-line argument based merge-sort sorting algorithm.
Format for command-line-...
3
votes
2
answers
182
views
Merge sort implementation in python 3
I have implemented a Merge sort in Python 3, and it works well. If anything needs to be improved, I would appreciate the criticism.
...
3
votes
1
answer
498
views
Iterative Merge Sort Algorithm (Python)
Merge Sort
Merge Sort algorithm is a general-purpose comparison-based sorting algorithm.
Most implementations produce a stable sort, in which the order of equal elements is preserved.
Here, our ...
1
vote
2
answers
187
views
Merge k sorted lists in Java
I hava a question similiar with mege in Python but I am trying to write Java code.
Here is my code:
The input is: The first line - a number of arrays (k); Each next line - the first number is the ...
5
votes
4
answers
606
views
MergeSort in Javascript
I implemented the following mergesort algorithm in JavaScript, but I want to know your opinion about if is possible to do better than this.
...