Ayu-hack / Hacktoberfest2024-1

This is repo to create some pull requests and completing hacktoberfest 2024 easily. All request will be accepted. Genuine Pull Request will promoted also. #hacktobefest #hacktobefest2024 #hacktobefest-accepted Resources
46 stars 467 forks source link

Added Heap Sort implementation in C++ with heapify function #179

Closed Acuspeedster closed 1 month ago

Acuspeedster commented 1 month ago

This commit adds an implementation of the Heap Sort algorithm in C++. The code includes the following:

heapify function: Ensures the subtree rooted at a given index satisfies the max-heap property. heapSort function: Builds a max-heap and sorts the array in-place by repeatedly moving the largest element to the end of the array and reducing the heap size. printArray function: A utility function to display the contents of the array before and after sorting. The algorithm has a time complexity of 𝑂 ( 𝑛 log ⁡ 𝑛 ) O(nlogn) and is efficient for in-place sorting.

Ayu-hack commented 1 month ago

PLEASE REF README .