Questions tagged [quick-sort]
Quicksort is a sorting algorithm invented by C. A. R. Hoare that has an average-case complexity of O(n log n), worst-case complexity of O(n^2). It is one of the fastest general-purpose sorting algorithms in practice.
171 questions
0
votes
3
answers
222
views
C# quicksort implementation (LeetCode Sort an Array)
I implemented quick sort after merge sort as part of LeetCode question for sorting an array. The solution code can be found at https://leetcode.com/problems/sort-an-array/solutions/7180269/i-...
4
votes
1
answer
340
views
c++ quicksort pivots
Is this code for quicksort using the first index as a pivot correct?
Also if I want to use the last or middle index as a pivot how would the whole code change?
...
3
votes
1
answer
98
views
Creating Worst-Case Scenario for QuickSort using Middle Pivot in Java
I've implemented a solution to generate the worst-case scenario for QuickSort using the middle pivot strategy in Java. The goal is to rearrange an input array to produce the worst performance during ...
4
votes
4
answers
1k
views
Quick Sort Done Lucidly
I've been away from Programming and the Tech Industry for sometime. I thought I'd look at and try some of the older basic stuff. I bushed up to QuickSort and found most existing implementations of it, ...
3
votes
3
answers
209
views
In-place recursive quick sort in C
Here's my second program in C, and my time/space analysis of this code.
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 ...
2
votes
2
answers
225
views
Quick Sort Program
Quick sort is a sorting algorithm in which we select any random element as pivot from the array and we do the partition of the array around that pivot. Basically we place all the elements smaller than ...
1
vote
1
answer
182
views
K-Way Partitioning QuickSort
I have implemented the K-Way Partitioning algorithm which is based on the Peter Taylor's solution.
Which works but i want fill the q array which is the borders of ...
3
votes
1
answer
383
views
High performance 3 Way Quick Sort Implementation
My implementation of 3 way quick sort for strings.
It supposed to sort very large set of 800,000,000 objects.
This is why I added ...
3
votes
0
answers
139
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 ...
2
votes
1
answer
788
views
non recursive quick sort in c++
I'm relatively new to c++ programming. I have a few years of experience writing simple Arduino programs, but I always kept to the basics. I also have some more experience with Python.
I set myself the ...
5
votes
2
answers
276
views
Case-insensitive sort in C
I wrote a sorting program so that if the optional argument -i is present then the sorting should be done without taking into account lowercase / uppercase letters.
...
1
vote
1
answer
2k
views
In place QuickSort algorithm in Python
I have been searching for ways to make my algorithm more efficient but most answers told me to divide the array into two differente arrays one of less elements and one of greater elements and then ...
0
votes
1
answer
73
views
Quicksort Invariant and steps to determine correcteness
I am having trouble with applying to 3 steps needed to proof correctness, most likely because I did not formally study CS or Mathematics and am still learning about loop and class invariants. The ...
3
votes
1
answer
1k
views
Quicksort using generics in java
The goal is to have a function that can sort a series of all object types that implement the comparable interface. I'm not trying to improve the performance of the sort. I'm only trying to optimize my ...
3
votes
2
answers
190
views
Recursive quick sort in python
I was wondering if there is anything that I could do to make my code look cleaner and more descriptive for educational purposes?
...
1
vote
2
answers
509
views
Python Quicksort Implementation with duplicates
Please critique my implementation of Quicksort in python 3.8:
...
1
vote
1
answer
145
views
Java generic 3-median quicksort
My generic 3 median quicksort:
...
3
votes
1
answer
1k
views
Quicksort using Lomuto partition scheme in C
This is my implementation of the divide-and-conquer Quicksort algorithm using the Lomuto partition scheme in C. This is part of a personal project and I'm following Linus Torvalds's coding style.
<...
5
votes
1
answer
194
views
Quicksort Algorithm Speed
I have made a sorting algorithm in Python 3. This sorting algorithm is a modified optimized median of 3 quicksort, with network sorting for lists of size up to 16 and for finding the median. I have ...
1
vote
1
answer
244
views
MSD Quick Radix Sort in Place in C++, Object/Pointer Oriented
Memory: O(log2(max)*2)~O(1)
Speed: O(log2(max)*n)~O(n)
so i did before a MSD Radix Sort in place but i wanted to do one, with out the count, So i join together the quick sort and radix sort. Think as ...
1
vote
1
answer
134
views
Generic QuickSort with Performance Optimised Swap for small types
Overview
A "from scratch" generic quicksort implemented in C, which allows predicate (returning bool, like C++ rather than ...
3
votes
2
answers
177
views
Quicksort implementation in JavaScript
I implemented Quicksort in JavaScript. I'm trying to follow the best principles in JavaScript. In Ruby when you declare classes your able to use private for the ...
3
votes
2
answers
170
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 ...
2
votes
0
answers
93
views
Python's quicksort algorithm
I was playing around with sorting methods, brushing up on my algorithms. I have made the following implementation of quicksort:
...
1
vote
2
answers
207
views
QuickSort Algorithm (Python)
This is my implementation of Quick Sort Algorithm :
...
0
votes
1
answer
70
views
3
votes
2
answers
81
views
Radix sort is deceiving
I wanted to compare radix_sort to quick_sort for values limited to 0..127 so I implemented this :
...
1
vote
1
answer
189
views
Is this a correct implementation of quicksort in C?
I'm learning C at the moment and chose implementing quicksort as an exercise.
My code is sorting correctly, but afterwards I looked at some tutorials online about quicksort. And they implement it ...
3
votes
1
answer
132
views
C# Quicksort Assignment
For my CS minor I was assigned to implement the Quicksort algorithm in C#. I gave it a go and found that I like the implementation of the algorithm more than Mergesort. Now that I've got my Quicksort ...
2
votes
1
answer
352
views
Quick sort algorithm in Rust
I have written this Rust code to implement the quick sort algorithm. Could you review it and tell me if it is idiomatic or not? Especially about my use of the slices?
...
4
votes
2
answers
392
views
Improving quick sort algorithm (Python)
I'm learning algorithm and this is my implementation of quick sort, please guide how can i improve it further and what are other more optimal ways to implement quick sort?
...
5
votes
1
answer
651
views
Reverse quick sort in Fortran
I have written a quick sort routine to inplace sort an array in descending order:
...
3
votes
1
answer
86
views
Quick Sort implementation in python
Implemented the quick sort algorithm in python, It was just for learning it, now I want to port it to C.
Thoughts on the quality of my python implementation?
...
7
votes
2
answers
1k
views
Quick Sort Implementation with iterators
Most quicksort examples online use C-style arrays and indexes. I have written below quicksort implementation with STL style iterators. It looks fine to me, but I feel like I may be making more than ...
3
votes
1
answer
200
views
Quick Sort Algorithm (Python)
QuickSort is a Divide and Conquer algorithm, which picks an element as "pivot" and partitions a given list around the pivot. There are many different versions of Quick Sort, as to how to pick a pivot ...
6
votes
3
answers
174
views
Quicksort for ints
I have written the following quicksort without using online help. It seems to be fine, but is there anything to improve?
...
7
votes
1
answer
240
views
Quicksort in JavaScript assuming an immutable array
Update: further succinct versions below (inspired by Haskell)
Quick sort in JS assuming an immutable array:
...
10
votes
1
answer
510
views
Engineering an even faster qsort
I understand that C++ STL template sort runs faster than qsort in C because ...
1
vote
0
answers
1k
views
Median of three partitioning taking more time than standard quicksort in java
I implemented a standard quicksort and I have a project where I need to improve it. I am trying to make quicksort faster by implementing median of 3 partitioning. I copied codes from trusted ...
9
votes
1
answer
891
views
Quicksort template (for sorting corresponding arrays)
I needed a function for sorting two corresponding arrays. So I wrote this code to sort N corresponding arrays!
The really "metaprogrammy" way to do it would be to use ...
1
vote
1
answer
405
views
Quicksort in C with unit testing framework
This is my quicksort
There are many like it but
This quicksort is mine.
So, quicksort, in C, with a big framework to test it six ways from Sunday. Passed the tests nicely, but there may be warts, or ...
1
vote
2
answers
165
views
Quick Sort c program
I recently learned quick sort through https://www.geeksforgeeks.org/quick-sort/ but found it hard to follow. So, from what I understand wrote the following program.
...
3
votes
2
answers
258
views
Evaluation of a variation of quick-sort (pivot-selection)
Here is a variation of quick-sort where-in the pivot selection is based on calculating the average of the values of the highest and lowest numbers.
...
1
vote
1
answer
961
views
Python implementation of Quicksort using list comprehensions
I wrote an implementation of quicksort that I think is pythonic. I based it off of this common Haskell implementation:
...
5
votes
2
answers
4k
views
Concurrent quicksort in C++
I have a task to write a concurrent version of quicksort algorithm, to speed it up. This is what I wrote:
...
1
vote
1
answer
120
views
Quicksort implementation with pivotal calculated as middle element
I read quick sort algorhitm and implemented in like this:
...
2
votes
1
answer
193
views
Pythonic quick sort
I'm new to the world of python, and wrote this quick sort implementation which was taught to us in an algorithms class. I would like to learn to write code less like C++ and more pythonic. Could you ...
3
votes
1
answer
171
views
Quicksort in JavaScript, using nested functions
I come from Java/Swift environment. So, I'm used to show the user of my code only "what is necessary".
For JavaScript I use Visual Code.
When I try to use the Intellisense feature, it shows all my ...
2
votes
0
answers
267
views
Classical Single Pivot QuickSort implementation in Java using Generics
I have coded the following quick sort implementation.
There are few things that still makes this code ugly and redundant.
1. Handling Arrays of Primitives
I have to write a separate implementation of ...
8
votes
1
answer
4k
views
Quick Sort in x86 assembly (MASM)
My task was to implement Quick Sort in assembly from pseudocode.
...