Use this tag with questions about the Quickselect algorithm, an algorithm to find the nth smallest member in a list.
Questions tagged [quickselect]
85 questions
0
votes
1 answer
Implementation of quick select in python. function is unstable and returns different values
I tried to implement quick select to find the m'th smallest number in the list. When I run the program it returns the correct values sometime and incorrect values other times on the same array. What am I doing wrong her is the code
def…

vishmay
- 386
- 2
- 4
- 15
0
votes
0 answers
How to use quick select to find the kth percentile number
Giving an integer array, the ninetieth percentile is the first number that exceeds 90% of the arrays. If you want more specific definition, please look at http://studentnet.cs.manchester.ac.uk/ugt/COMP26120/lab/ex6def.html
I have written a quick…

NUO
- 247
- 2
- 3
- 14
0
votes
2 answers
quickSelect algorithm to return kth smallest element
I have followed quickSelect to understand and implement quickSelect algorithm. One thing I am not sure here is : why do they do k-pivot and pivot-first+1.
Though my implementation is exactly similar to this link, it is not working.
#include…

Anil Kumar K K
- 1,395
- 1
- 16
- 27
0
votes
2 answers
AutoCAD C# call quick select dialog from new my form
Does anyone know how to show quick select dialog by click on button on my new autocad form.
I use SendStringToExecute method, but it sends the command after closed the dialog…
0
votes
2 answers
Quick Select Algorithm
I'm trying to implement the Quick Select Algorithm on an array that has randomly generated numbers. Now after coding the algorithm, it does not sort the array from lowest to highest nor am I able to find the kth smallest…

Mexus94
- 13
- 3
0
votes
1 answer
What is the worst case time complexity of median of medians quicksort?
What is the worst case time complexity of median of medians quicksort ( pivot is determined by the median of medians which take O(n) time to find )?

Naman Jain
- 63
- 1
- 9
0
votes
2 answers
Implementing quickselect
I'm trying to implement the quickselect algorithm. Though, I have understood the theory behind it very well; I'm finding it difficult to convert it into a well functioning program.
Here is how I'm going step by step to implement it and where I am…

krtkush
- 1,378
- 4
- 23
- 46
0
votes
1 answer
Weird bug in median of medians as pivot to find Kth max element
Finally I found the bug, please look at the second EDIT
But there is still that question, you see, the last fourth row of "getMedian()" method, I sort the medians[] array to find the median of medians. Personally I think this breaks the worst case…

zproject89
- 225
- 5
- 19
0
votes
1 answer
Find Kth min elem by randomized pivot method. Some weird bug
I try to use "randomized pivot" method to find the Kth min elem among given array.
[The code]
public class FindKthMin {
// Find the Kth min elem by randomized pivot.
private static void exchange (int[] givenArray, int firstIndex, int secondIndex)…

zproject89
- 225
- 5
- 19
0
votes
2 answers
Cant understand Quick Select Algorithm
I am having a problem understanding the Quick select algorithm. I know it is based on the Quick sort algorithm (which I am familiar with) and that it gives you the required result perhaps leaving a portion of the array unsorted.Now here is where I…

Rajeshwar
- 11,179
- 26
- 86
- 158
0
votes
2 answers
Return the top K elements from an input array
I am looking for efficient way to return top k elements from an input array.
One way would be to sort the array and return the k elements from end of array.
There are other methods suggested here, one of which uses the quickselect algorithm, but…

brain storm
- 30,124
- 69
- 225
- 393
0
votes
1 answer
find approx median in unsorted list
i want to find approx median in unsorted list,i know two algorithm
algorithm 1- quickselect
algorithm 2- Median of medians
i can't use quickselect in my project because it take O(n^2) in worst case.
i heard about Median of medians,but my colleagues…

asd
- 215
- 3
- 9
0
votes
1 answer
How do you find multiple ki smallest elements in array?
I am struggling with my homework and need a little push- the question is to design an algorithm that will in O(nlogm) time find multiple smallest elements 1

user2067051
- 99
- 2
- 15
0
votes
1 answer
Python: Unsorted/Sorted Lists Return Different Values?
Working on some stuff and I came into an odd issue that I am having trouble figuring out. I am sorting a list with 10,000 values in it two ways, one with the usage of quick select, and another with the usgae of insertion sort. The goal of this is to…

BLU
- 121
- 1
- 2
- 7
0
votes
1 answer
How would quickselectg act differently if pivot wasn't the middle term
Alright so I have developed a generic quickselect function and it is used to find the median of a list.
k = len(aList)//2 and the list is aList = [1,2,3,4,5]
So how would the program act differently if pivot started at the first item of the list…

user123456789101112
- 55
- 1
- 4
- 15