Skip to content

Conversation

@omuphade77
Copy link

… fix binary search

🔍 Summary

This pull request adds a new implementation of the QuickSelect algorithm to efficiently find the Kth largest element in an array.
It also includes a benchmark comparison script and README documentation for better understanding and testing.


🧩 Files Added

  • quickselect.cpp → Implements the QuickSelect algorithm (average O(n) time)
  • compare_methods.cpp → Benchmarks Sorting, nth_element, and QuickSelect methods
  • README.md → Detailed explanation, complexity table, and usage instructions

⚙️ Features

  • New algorithm with linear average time complexity.
  • Performance comparison between existing methods.
  • Clear documentation for new contributors.
  • Consistent naming and code formatting.

🧠 Improvements / Benefits

  • Provides a faster alternative to heap-based methods.
  • Encourages modular code and benchmarking.
  • Makes the “Kth Largest” folder more complete and educational for contributors.

✅ Testing

Tested locally on multiple input arrays:
Input: [3,2,3,1,2,4,5,5,6], k=4
Output: 4
Results from all methods are consistent.


📈 Future Enhancements

  • Add randomized and median-of-medians versions of QuickSelect.
  • Integrate automated test file (test_kth_largest.cpp).
  • Visualize runtime using a Python plot.

Closes:

@welcome
Copy link

welcome bot commented Oct 27, 2025

Thanks for opening this pull request! Please be sure that you have checked out our contributing guidelines.

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.

1 participant