@ts-standard-library/algorithms
Version:
A collection of algorithms for TypeScript.
13 lines (12 loc) • 592 B
TypeScript
/**
* Sorts an array of numbers in ascending order using the heap sort algorithm.
*
* Heap sort is an in-place, comparison-based sorting algorithm with O(n log n) time complexity.
* This implementation modifies the input array and returns the sorted array.
*
* @param array - The array of numbers to sort.
* @returns The sorted array in ascending order.
* @see [Heap Sort Visualization](https://www.geeksforgeeks.org/heap-sort/)
* @see {@link https://en.wikipedia.org/wiki/Heapsort} for more information on heap sort.
*/
export declare function heapSort(array: number[]): number[];