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
2
votes
0
answers
249
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.
...
4
votes
1
answer
1k
views
QuickSort in Java with Lomuto Partition or Hoare Partition
I have developed a quick sort in java, that can work with both Lomuto Partition Strategy, or Hoare Partition Strategy.
Both of them sort the array correctly.
I would like to have it code reviewed ...
7
votes
2
answers
5k
views
Quick Sort on C++ vector
I've seen other implementations around, but they seem pretty complicated. This seems to work for me, but is there anything I'm missing? Also, any tips on how I can improve the quality of the code is ...
2
votes
3
answers
569
views
Quick sort with a predicate
I want to pass a predicate into quick sort. The issue I'm running into is that the predicate must have two arguments, the pivot and the element of the list's tail. As far as I know though, predicates ...
0
votes
1
answer
3k
views
Quick sort implemented in Rust
First attempt at writing Rust code. What do you think of the formatting? I think the type conversions are pretty messy. How can I make it more idiomatic?
...
2
votes
2
answers
11k
views
Sorting an ArrayList of Vehicles using quick sort
For an assignment I have to sort an ArrayList of Vehicle objects using the quick sort method. I have come up with two implementations for this, which would be the best to use? Is method 1 considered ...
3
votes
2
answers
485
views
First quicksort algorithm
The program is separated in main.cpp, quicksort.cpp, partition.cpp and swap.cpp. There is also a header file to each .cpp file. The idea is from this site.
As you can see, I tried to be very modular. ...
4
votes
2
answers
811
views
Quicksort implementation in C++
I was wondering if this implementation of quicksort could be improved. Are there any things that I have done wrong?
...
3
votes
3
answers
2k
views
Quick Sort C++ Implementation
I'm learning C++ and algorithms myself, and as training I had to write quicksort by myself.All feedback on coding style/clarity and concepts are welcomed!
...
5
votes
1
answer
4k
views
Iterative in-place quicksort
I have implemented an iterative in-place quicksort algorithm in Python, which by default selects the pivot as the last element:
...
0
votes
1
answer
17k
views
Sort data from a text file in descending order using quick sort
I have a text file containing the following data.
...
1
vote
1
answer
1k
views
Iterative quicksort in Java
I have this quicksort implementation that relies on heap memory instead of actual stack. It uses two integer stacks for keeping track what subranges are yet to be sorted. When a partition routine is ...
3
votes
3
answers
466
views
10
votes
4
answers
3k
views
Quick Sort Implementation C++11
Here is qsort implementation using iterators as it is in std::sort
...
2
votes
2
answers
385
views
A Concise Quick Sort
This is an implementation of Quick Sort in JS. Can this implantation of Quick Sort be more concise and efficient while still remaining expressive?
...
5
votes
1
answer
1k
views
Mergesort vs Quicksort Timing in Python
I have implemented Mergesort and Quicksort in Python and have noticed that Quicksort runs two times as fast as Mergesort. Is this a property of the algorithm or is Mergesort coded inefficiently? Are ...
2
votes
1
answer
933
views
Quicksort implementation in TASM assembly
Is this assembly (TASM) implementation of quicksort efficient, and does this code follow common best practices?
...
3
votes
1
answer
252
views
Iterator based version of quicksort, allowing user defined pivot-selection-strategy
I have implemented a iterator based version of Quicksort, which allows the user to define and pass his own pivot-selection-strategy:
...
8
votes
1
answer
87
views
Yet another quicksort
Code review my quicksort! It isn't supposed to be superfast or anything and doesn't basecase out to insertion sort or anything. It's optimized for clarity and only sorts arrays of pointers.
...
9
votes
2
answers
4k
views
Fast quicksort implementation
Just for learning purposes i wrote an implementation of quicksort algorithm.
I made some modifications to the algorithm to make it faster, that are:
two pivots setted to the boundaries of the middle ...
0
votes
1
answer
360
views
C++ implementation of quicksort with iterators (unstable sorting)
Please review the following quicksort implementation.
qsort below is intentionally unstable, as partition reoders equal elements....
2
votes
2
answers
277
views
Java class for sorting arrays based upon QuickSort algorithm
Hint: This question is a follow-up to my Code Review question from 09.01.2017: Class sort with BubbleSort algorithm
After been showed Mergesort and QuickSort as pseudo-code this week in lecture ...
4
votes
1
answer
303
views
Quicksort in JavaScript using destructuring and spread syntax
I'm learning Haskell, and there was quicksort implementation, so I thought that I could implement it in a similar way in JavaScript. The result:
...
5
votes
2
answers
792
views
Double-Pivot Quicksort in C
I've added a sort function to my library of utility functions. I will need to extend its behaviour at a later time but for now it's just a replacement for the ...
-1
votes
1
answer
6k
views
QuickSort Median of Three V2
Unfortunately, my earlier question was put on hold due to "code that doesn't work", but I realised that there were holes in my question, so here it is again, revamped.
You probably know the QuickSort ...
1
vote
2
answers
296
views
Determine if a string of characters are unique using quicksort
This will determine if a string is unique or not using quicksort, so that it should take \$O(nlogn)\$ time and not \$O(n^2)\$ time.
I will call the test function ...
-2
votes
1
answer
119
views
Manually sorting in PHP [closed]
I had read about quicksort in some articles. Is this is a correct implementation of quicksort?
...
6
votes
5
answers
16k
views
Quick sort algorithm
Is this algorithm good or can I improve it?
...
2
votes
1
answer
100
views
Quick sort implemented in Python
This code implements quick sort and takes advantage of passing the list by reference. I'm looking for performance and general best practices.
...
5
votes
2
answers
2k
views
Parallel quicksort algorithm taking way too long
Below is a Python implementation of the quicksort algorithm using parallelism. It takes about 1 second per every 10 items in the list, which is hilariously unacceptable. Why is it so slow?
...
3
votes
1
answer
2k
views
Implementing a Generic Quick Sort With Various Optimizations
I decided for educational purpose to make a generic sort like the one in the standard library as an exercise for my self in learning more about how to do generic programming in C and so I would really ...
0
votes
2
answers
2k
views
4
votes
1
answer
189
views
My Quick sort examination
I had a test on sorting using quick sort algorithm, which I have implemented. It's working fine.
But my examiner is not satisfied. They say that the solution which I provided is not a proper ...
3
votes
2
answers
3k
views
Quicksort using first element pivot
I'm trying to get my Quicksort implementation doing fewer comparisons. The first element is used as a pivot. Could you give me some directions if there are any places that should be optimized in a ...
4
votes
1
answer
152
views
Quicksort using uniform_int_distribution to select the pivot
I have not used C++ for a while. Could you please tell me if my usage of the <random> module is correct? I am not sure if I need to be creating a new instance ...
5
votes
2
answers
4k
views
Quick Sort in Java
I recently started learning about algorithms and data structure's. I decided that for every algorithm I learn about I'll implement it without looking at any pseudo code or actual code.
I have ...
2
votes
3
answers
771
views
QuickSort C++ Implmentation using Iterators #2
This is part 2 of the previous question asked which is at - QuickSort C++ Implementation using Iterators.
Based on Jerry Coffin's answer, I have made the changes except for using templates.
...
2
votes
1
answer
148
views
Quick sort implementation
Please look the code below
...
7
votes
2
answers
5k
views
QuickSort C++ Implementation using Iterators
I implemented quicksort using iterators. I am will be grateful, if someone can review my piece of code. BTW, I am just selecting the last element as the pivot (which I plan to randomize later) I am ...
6
votes
1
answer
493
views
Quicksort implementation in Go
Learning Go and trying to get a grip of the various concepts it uses. Following is my implementation of Quicksort (choosing last element as pivot). It takes the length of the array and the subsequent ...
3
votes
1
answer
223
views
C++11 Quicksort any container
As the title says, simple quicksort to help myself get used to C++ templates and iterators. Main concern is whether there's a better way to template so that you can have a simple function (e.g. ...
2
votes
1
answer
3k
views
Median of 3 Quicksort in C
I'm trying to re-implement the C stdlib function qsort using a median of 3 quicksort.
...
5
votes
1
answer
846
views
Quicksort implementation in Java
I wrote this implementation of quicksort as a bit of practice and review for myself. I did not base my algorithm on anything more than my own understanding of quicksort and working through a couple ...
3
votes
2
answers
5k
views
Parallel integer Quicksort in Java
Now I have that parallel Quicksort for (primitive) integer arrays.
ParallelIntQuicksort.java:
...
3
votes
1
answer
655
views
Faster QuickSort
I'm trying to make my QuickSort faster than it is and I have got no more ideas about how to make it more efficient for all types of arrays but mostly very big arrays. It uses random to create the ...
3
votes
2
answers
124
views
Quicksort for a pseudosite
I have a pseudosite, where I actually post small functions, so that I can re-use them*, but some posts have visitors. The top is Quicksort (C++). I feel that beginners visit it, so I do not care in ...
10
votes
3
answers
1k
views
Integer quicksort in Java
I have this Quicksort implementation that sorts arrays of int (not Integer). It has comparable performance to Java's ...
9
votes
1
answer
8k
views
Multi-dimensional array sort and filter functions
As I said in my last post Multi-dimensional ascending and descending sort array function, I'm back with the final version of the code.
Added features:
Filter array function by following parameters: <...
6
votes
3
answers
5k
views
Quicksort for strings in Java
I have this implementation of Quicksort for strings. The algorithm sorts the requested range by first character, then by second, third, and so on. (Please, do not confuse this with radix sort; it is ...