Add Median of Two Sorted Arrays Algorithm to Divide and Conquer Section #1
+112
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📝 Summary
This pull request implements the Median of Two Sorted Arrays algorithm using an efficient divide-and-conquer approach, addressing issue TheAlgorithms#13717.
🎯 What does this PR do?
Adds a new algorithm that finds the median of two sorted arrays in logarithmic time complexity. This is a classic computer science problem that demonstrates the power of the divide-and-conquer paradigm.
📂 Files Added
divide_and_conquer/median_of_two_sorted_arrays.py- Main implementation with comprehensive documentation✨ Implementation Highlights
Algorithm Features:
How It Works:
The algorithm uses a partition-based approach:
✅ Testing
The implementation includes 10 comprehensive doctests covering:
All tests pass successfully! ✨
python3 -m doctest divide_and_conquer/median_of_two_sorted_arrays.py -v # Result: 10 passed and 0 failed🔗 Related Issue
Closes TheAlgorithms#13717
📚 Code Quality
🚀 Why This Matters
This algorithm is:
🙏 Acknowledgments
Thanks to @devdandekar24 for opening this issue and to the maintainers of TheAlgorithms/Python for maintaining this excellent learning resource!
Ready for review! Happy to make any adjustments based on feedback. 😊