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.

Filter by
Sorted by
Tagged with
6
votes
3answers
89 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
1answer
98 views

Quicksort in JavaScript assuming an immutable array

Update: further succinct versions below (inspired by Haskell) Quick sort in JS assuming an immutable array: ...
7
votes
0answers
82 views

Engineering an even faster qsort

I understand that C++ STL template sort runs faster than qsort in C because ...
1
vote
0answers
65 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 ...
1
vote
0answers
58 views

Median of 3 partitioning taking more time than quicksort in java

I have a quicksort code in java which I want to improve. The improved code should take less time than the quicksort code. However when using my improved code which implement median of 3 partitioning, ...
1
vote
0answers
45 views

Sorts (merge, quick, bubble) in Python

I'm new to python, and I wrote the following code. Please review, critique and enhance. This project compares quicksort, mergesort and bubblesort write/test the partition routine for ...
6
votes
0answers
103 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
1answer
78 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 ...
0
votes
2answers
73 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. ...
1
vote
0answers
126 views

Qsort in C++ using vector

I tried to make a simple qsort() function in a functional way, it takes a vector and a bool pred() Suggestions as to make it more functional, optimize it, and/or ...
3
votes
2answers
118 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
1answer
144 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
2answers
1k 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
1answer
56 views

Quicksort implementation with pivotal calculated as middle element

I read quick sort algorhitm and implemented in like this: ...
2
votes
1answer
85 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
1answer
99 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
0answers
58 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 ...
6
votes
1answer
1k views

Quick Sort in x86 assembly (MASM)

My task was to implement Quick Sort in assembly from pseudocode. ...
4
votes
1answer
544 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
2answers
3k 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
3answers
108 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
1answer
680 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? ...
1
vote
0answers
484 views

Quick Sort Implementation on Python

I tried to implement quick sort. Quick sort is a divide and conquer algorithm. It continues to choose a pivot point and break down the collection into single-element lists, before combing them back ...
1
vote
2answers
5k 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
2answers
333 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
2answers
539 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
3answers
1k 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
1answer
2k 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: ...
1
vote
0answers
386 views

Last element pivot Quicksort exercise in TypeScript

Never being good in "algorithming", I'm now trying to improve the situation a bit. An algorithm below is the attempt to home brew yet another quicksort. This time, specifically with a "last-element" ...
0
votes
1answer
13k views

Sort data from a text file in descending order using quick sort

I have a text file containing the following data. ...
1
vote
1answer
837 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 ...
2
votes
3answers
174 views
10
votes
4answers
2k views

Quick Sort Implementation C++11

Here is qsort implementation using iterators as it is in std::sort ...
2
votes
2answers
303 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? ...
4
votes
1answer
757 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
1answer
593 views

Quicksort implementation in TASM assembly

Is this assembly (TASM) implementation of quicksort efficient, and does this code follow common best practices? ...
3
votes
1answer
181 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: ...
5
votes
0answers
58 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
2answers
1k 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
1answer
182 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
2answers
237 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
1answer
257 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
2answers
473 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
1answer
3k 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
0answers
53 views

Java quicksort in logarithmic space

I have this quicksort implementation that guarantees that the recursion depth will be at most logarithmic in \$n\$: LogQuicksort.java ...
1
vote
2answers
267 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
1answer
99 views

Manually sorting in PHP [closed]

I had read about quicksort in some articles. Is this is a correct implementation of quicksort? ...
4
votes
5answers
12k views

Quick sort algorithm

Is this algorithm good or can I improve it? ...
2
votes
1answer
87 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
2answers
923 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? ...