Stack Exchange Network

Stack Exchange network consists of 175 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 [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.

7
votes
0answers
62 views

Engineering an even faster qsort

I understand that C++ STL template sort runs faster than qsort in C because ...
0
votes
0answers
54 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
44 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
37 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 ...
5
votes
0answers
102 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
73 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 ...
4
votes
1answer
148 views

Hackerrank “Almost Equal” solution

I've spent the best part of a day on this question. It is marked as Expert level. There are about fifteen submission test cases and my solution manages to satisfy the first four. However, from there ...
0
votes
2answers
71 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
104 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
115 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
119 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
53 views

Quicksort implementation with pivotal calculated as middle element

I read quick sort algorhitm and implemented in like this: ...
2
votes
1answer
73 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
95 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
948 views

Quick Sort in x86 assembly (MASM)

My task was to implement Quick Sort in assembly from pseudocode. ...
4
votes
1answer
488 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
106 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
559 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
456 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
4k 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
321 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
530 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
377 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
12k 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
801 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 ...
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
288 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
702 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
562 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
172 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
57 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
177 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
233 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
251 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
463 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
265 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
93 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
11k views

Quick sort algorithm

Is this algorithm good or can I improve it? ...
2
votes
1answer
86 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
874 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? ...
2
votes
1answer
944 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 ...