Skip to content

feat: add quick select algorithm and test #6 #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

prisojacques
Copy link
Contributor

@prisojacques prisojacques commented Jun 26, 2023

QuickSelect is an efficient algorithm for finding the kth smallest element in an unsorted array. It uses a partitioning technique similar to QuickSort to divide the array and narrow down the search range. With an average time complexity of O(n), QuickSelect is a powerful tool for retrieving specific elements without sorting the entire array.

Copy link
Contributor

@appgurueu appgurueu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can you speak of a "worst case" and a "best case" when your QuickSelect is randomized? Whether partition splits evenly will depend on the random pivot which is chosen rather than the order of the array.

Please just generate a few random arrays, QuickSelect a few items, then sort the array and compare the results.

Side note: Your description feels like it was written by ChatGPT. Please do not dump chatbot spam on us. If it was written by you, please be aware that you don't need to add a completely redundant explanation of what the code does in the PR; what the code does should be clear from the code through good variable naming and comments.

@raklaptudirm raklaptudirm merged commit 0fa510b into TheAlgorithms:master Jul 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants