Skip to main content

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [mergesort]

For code that implements a merge sort or a significant part of it

Filter by
Sorted by
Tagged with
2 votes
1 answer
91 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: ...
Akash Gupta's user avatar
4 votes
3 answers
1k views

Java class subset of C++ std::list with efficient std::list::sort()

Issues with generics < E > and < E extends Comparable > in code below. What changes are needed in the code below to prevent DLList.push_front() and DLList.push_back() from accepting ...
rcgldr's user avatar
  • 284
1 vote
3 answers
118 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 ...
Voiceroy's user avatar
  • 113
2 votes
1 answer
90 views

Implementing an improved merge sort that uses insertion sort, with "levels" - Would this work correctly?

We were asked to improve the merge sort algorithm by introducing insertion sort to the code. We have been tasked with doing this by utilising a "levels" logic. Here is the exact description ...
Preatorius's user avatar
1 vote
1 answer
125 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: ...
coderodde's user avatar
  • 31.9k
12 votes
4 answers
2k views

Recursive merge sort in C

Here's my first program in C, which is not my first language. I have been reading Modern C and I attempted this challenge on page 26. The prior pages are pretty much the only exposure I have had to C, ...
user14464173's user avatar
2 votes
1 answer
76 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 ...
Thomas Mathew's user avatar
3 votes
0 answers
127 views

Destructive quick and merge sort

I've implemented a destructive merge and quick sort in common lisp, but the code feels verbose and highly imperative. I was wondering if anyone could offer guidance on idioms that could make the code ...
bfair's user avatar
  • 131
3 votes
2 answers
264 views

C++ merge sort, logging, unit test, performance check

I wrote a merge sort implementation in C++ today in C++20 way. ...
frozenca's user avatar
  • 1,743
2 votes
3 answers
513 views

Adjusting heaps efficiently

Introduction and context I am working on a small application which involves sorting 20GB files as one of the operations. This is being done, due to memory constraints, by breaking them into ~1GB ...
Oliver Schönrock's user avatar
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 ...
nickhealy's user avatar
  • 165
3 votes
1 answer
147 views

Optimize mergesort algorithm

I just started Stanford Coursera algorithms course and I wrote this mergesort based on what was shown: ...
Aayush's user avatar
  • 61
1 vote
2 answers
180 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; ...
Krokodil's user avatar
  • 123
3 votes
1 answer
108 views

IOSP Kata: merge two sorted arrays without iterators

I wrote the code below as a Kata to practice the Integration Operation Segregation Principle (IOSP, clean-code-developers.com). I would like to have some feedback ...
Turing85's user avatar
  • 137
1 vote
2 answers
109 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: ...
DivijM's user avatar
  • 111

15 30 50 per page
1
2 3 4 5
20
Morty Proxy This is a proxified and sanitized view of the page, visit original site.