Skip to main content

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
0 votes
3 answers
222 views

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-...
Dovud Jo'rayev's user avatar
4 votes
1 answer
340 views

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? ...
Kqehzo's user avatar
  • 41
3 votes
1 answer
98 views

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 ...
Lydia Yuan's user avatar
4 votes
4 answers
1k views

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, ...
Amal Krishnan's user avatar
3 votes
3 answers
209 views

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 ...
user14464173's user avatar
2 votes
2 answers
225 views

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 ...
Strange Alchemist's user avatar
1 vote
1 answer
182 views

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 ...
user avatar
3 votes
1 answer
383 views

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 ...
Nick's user avatar
  • 1,656
3 votes
0 answers
139 views

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
2 votes
1 answer
788 views

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 ...
iHnR's user avatar
  • 121
5 votes
2 answers
276 views

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. ...
Mike's user avatar
  • 319
1 vote
1 answer
2k views

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 ...
Luigi_S_R's user avatar
0 votes
1 answer
73 views

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 ...
MPC's user avatar
  • 61
3 votes
1 answer
1k views

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 ...
BugSquanch's user avatar
3 votes
2 answers
190 views

I was wondering if there is anything that I could do to make my code look cleaner and more descriptive for educational purposes? ...
Farzin's user avatar
  • 133
1 vote
2 answers
509 views

Please critique my implementation of Quicksort in python 3.8: ...
fricadelle's user avatar
1 vote
1 answer
145 views

My generic 3 median quicksort: ...
NoobProgrammer's user avatar
3 votes
1 answer
1k views

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. <...
Andy Sukowski-Bang's user avatar
5 votes
1 answer
194 views

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 ...
Sola Sky's user avatar
  • 113
1 vote
1 answer
244 views

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 ...
bigotes0invisibles's user avatar
1 vote
1 answer
134 views

Overview A "from scratch" generic quicksort implemented in C, which allows predicate (returning bool, like C++ rather than ...
Oliver Schönrock's user avatar
3 votes
2 answers
177 views

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 ...
Steven Aguilar's user avatar
3 votes
2 answers
170 views

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 ...
FlatAssembler's user avatar
2 votes
0 answers
93 views

I was playing around with sorting methods, brushing up on my algorithms. I have made the following implementation of quicksort: ...
revliscano's user avatar
1 vote
2 answers
207 views

This is my implementation of Quick Sort Algorithm : ...
soufiane yes's user avatar
3 votes
2 answers
81 views

I wanted to compare radix_sort to quick_sort for values limited to 0..127 so I implemented this : ...
nowox's user avatar
  • 1,121
1 vote
1 answer
189 views

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 ...
Miha's user avatar
  • 53
3 votes
1 answer
132 views

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 ...
Timon de Groot's user avatar
2 votes
1 answer
352 views

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? ...
Sebastien's user avatar
  • 123
4 votes
2 answers
392 views

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? ...
Mist's user avatar
  • 43
5 votes
1 answer
651 views

I have written a quick sort routine to inplace sort an array in descending order: ...
ipcamit's user avatar
  • 153
3 votes
1 answer
86 views

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? ...
StackOverflowToxicityVictim's user avatar
7 votes
2 answers
1k views

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 ...
Aykhan Hagverdili's user avatar
3 votes
1 answer
200 views

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 ...
Emma Marcier's user avatar
  • 3,742
6 votes
3 answers
174 views

I have written the following quicksort without using online help. It seems to be fine, but is there anything to improve? ...
K_peanutButter's user avatar
7 votes
1 answer
240 views

Update: further succinct versions below (inspired by Haskell) Quick sort in JS assuming an immutable array: ...
coder_bro's user avatar
  • 419
10 votes
1 answer
510 views

I understand that C++ STL template sort runs faster than qsort in C because ...
Neil's user avatar
  • 1,112
1 vote
0 answers
1k views

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 ...
teddy's user avatar
  • 11
9 votes
1 answer
891 views

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 ...
Quuxplusone's user avatar
  • 19.7k
1 vote
1 answer
405 views

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 ...
Tom Zych's user avatar
  • 421
1 vote
2 answers
165 views

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. ...
Khushit Shah's user avatar
3 votes
2 answers
258 views

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. ...
Ravindra HV's user avatar
1 vote
1 answer
961 views

I wrote an implementation of quicksort that I think is pythonic. I based it off of this common Haskell implementation: ...
Bret Fontecchio's user avatar
5 votes
2 answers
4k views

I have a task to write a concurrent version of quicksort algorithm, to speed it up. This is what I wrote: ...
minecraftplayer1234's user avatar
1 vote
1 answer
120 views

I read quick sort algorhitm and implemented in like this: ...
gstackoverflow's user avatar
2 votes
1 answer
193 views

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 ...
KKP's user avatar
  • 297
3 votes
1 answer
171 views

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 ...
SkrewEverything's user avatar
2 votes
0 answers
267 views

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 ...
Nataraj's user avatar
  • 21
8 votes
1 answer
4k views

My task was to implement Quick Sort in assembly from pseudocode. ...
William's user avatar
  • 539