Skip to content

Add Heap Sort implementation in Python#224

Merged
Pradeepsingh61 merged 1 commit intomainfrom
add-python-heap-sort
Oct 1, 2025
Merged

Add Heap Sort implementation in Python#224
Pradeepsingh61 merged 1 commit intomainfrom
add-python-heap-sort

Conversation

@Karanjot786
Copy link
Copy Markdown
Collaborator

📝 Description

This PR adds a comprehensive Heap Sort algorithm implementation in Python with in-place sorting and helper functions.

📂 Files Added

  • Python/algorithms/sorting/heap_sort.py

✨ Features

  • Heapify function: Maintains max heap property for subtrees
  • Heap Sort: In-place sorting using heap data structure
  • Copy function: Returns sorted copy without modifying original array
  • Comprehensive test cases: 6 different test scenarios including:
    • Random unsorted array
    • Already sorted array
    • Reverse sorted array
    • Array with duplicates
    • Large array
    • Single element array

📊 Complexity Analysis

  • Time Complexity: O(n log n) in all cases (best, average, worst)
  • Space Complexity: O(1) - sorts in place with constant extra space

🔑 Key Concepts

  • Max heap construction from unsorted array
  • Heapify operation to maintain heap property
  • Extract-max and rebuild heap iteratively

✅ Testing

All test cases run successfully and demonstrate correct sorting behavior across different input scenarios including edge
cases.

🎃 Hacktoberfest 2025

This contribution is part of Hacktoberfest 2025. The code follows the repository's structure (Language/Topic/FileName) and
includes proper documentation.

📋 Checklist

  • Code follows repository structure (Python/algorithms/sorting/)
  • Proper documentation and comments added
  • Test cases included
  • Time and space complexity documented
  • No user input required (tests run automatically)
  • Code is well-formatted and readable

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Oct 1, 2025

🎉 Welcome to Hacktoberfest 2025, @Karanjot786! 🎃

Thank you for your first contribution to our DSA repository! Here's what happens next:

🔍 Automatic Checks

  • Code Validation: Passed
  • 🧪 Compilation Tests: Passed

📋 Next Steps

🎯 Great job! Your code compiled successfully. Maintainers @Karanjot786 and @Pradeepsingh61 will review your PR soon.

🎁 What You Get

  • 🏆 Hacktoberfest Credit: This PR counts toward your 6 PR goal for exclusive T-shirt + Tree!
  • 🌟 Hall of Fame: You'll be featured in our contributors list
  • 📚 Learning: Code review feedback from experienced developers

💡 Tips for Success

  • Follow our Contributing Guidelines
  • Add comments explaining your algorithm
  • Include time/space complexity analysis
  • Test your code before submitting

Welcome to the community! 🚀

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Oct 1, 2025

🤖 Automated PR Status

🔍 Code Validation

Passed - File naming and structure look good!

🧪 Compilation Tests

Passed - All code compiles successfully!

📋 Overall Status

🎉 Ready for Review - Your PR has passed all automated checks!
👥 Maintainers have been notified for review.


This comment was generated automatically. Checks will re-run when you push new commits.

@Pradeepsingh61 Pradeepsingh61 merged commit a2975ec into main Oct 1, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants