heaps/main.cpp
void buildHeap( int arr[], int n )
{
	// Index of last non-leaf node
	int startIdx = ( n / 2 ) - 1;

	// Perform reverse level order traversal
	// from last non-leaf node and heapify
	// each node
	for ( int i = startIdx; i >= 0; i-- )
	{
		heapify( arr, n, i );
	}
}
// Function to build a Max-Heap from the given array
Function to build a Max-Heap from the given array
Function to build a Max - Heap from the given array
void buildHeap( int arr[], int n )
{
	int startIdx = ( n / 2 ) - 1;
	for ( int i = startIdx; i >= 0; i-- )
	{
		heapify( arr, n, i );
	}
}
void buildHeap ( int arr [ ] , int n ) { int startIdx = ( n / 2 ) - 1 ; for ( int i = startIdx ; i >= 0 ; i -- ) { heapify ( arr , n , i ) ; } }
Function to build a Max-Heap from the given array
Function to build a Max - Heap from the given array
// Index of last non-leaf node // Perform reverse level order traversal // from last non-leaf node and heapify // each node