You iterate over http://latex.codecogs.com/gif.latex?%5Cleft&space;%5Clfloor&space;n/2&space;%5Cright&space;%5Crfloor elements (no leaf elements). Knowing this we can conclude that is at least O(n). The function called buildMaxHeap is actually O(h), h being the height of the node (which you call i). So because the height of any heap is http://latex.codecogs.com/gif.latex?%5Cleft&space;%5Clfloor&space;lg&space;n&space;%5Cright&space;%5Crfloor
http://latex.codecogs.com/gif.latex?%5Csum_%7Bh=0%7D%5E%7B%5Cleft&space;%5Clfloor&space;lg&space;(n)&space;%5Cright&space;%5Crfloor%7D%5Cleft&space;%5Clceil&space;%5Cfrac%7Bn%7D%7B2%5E%7Bh+1%7D%7D&space;%5Cright&space;%5Crceil&space;O(h)&space;=&space;O(n%5Csum_%7Bh=0%7D%5E%7B%5Cleft&space;%5Clfloor&space;lg&space;(n)&space;%5Cright&space;%5Crfloor%7D%5Cfrac%7Bh%7D%7B2%5E%7Bh%7D%7D)
http://latex.codecogs.com/gif.latex?%5Csum_%7Bh=0%7D%5E%7B%5Cinfty&space;%7D%5Cfrac%7Bh%7D%7B2%5E%7Bh%7D%7D&space;=&space;%5Cfrac%7B1/2%7D%7B(1-1/2)%5E%7B2%7D%7D&space;=2
You iterate over http://latex.codecogs.com/gif.latex?%5Cleft&space;%5Clfloor&space;n/2&space;%5Cright&space;%5Crfloor elements (no leaf elements). Knowing this we can conclude that is at least O(n). The function called buildMaxHeap is actually O(h), h being the height of the node (which you call i). So because the height of any heap is http://latex.codecogs.com/gif.latex?%5Cleft&space;%5Clfloor&space;lg&space;n&space;%5Cright&space;%5Crfloor
You iterate over n/2 floorhttp://latex.codecogs.com/gif.latex?%5Cleft&space;%5Clfloor&space;n/2&space;%5Cright&space;%5Crfloor elements (no leaf elements). So only byKnowing this we can conclude that you know is at least O(n). The function called buildMaxHeap is actually O(h) worst case, h being the height of the node (which you call i) in the heap. So because the height of any heap is http://latex.codecogs.com/gif.latex?%5Cleft&space;%5Clfloor&space;lg&space;n&space;%5Cright&space;%5Crfloor
buildMaxHeap doesn't actually builds the max heap so it shouldn't be named as it didname is not appropriate. This function is commonly called maxheapify and is to maintain the heap property. Also I would change the name of parameter named clone for something more generic, sincebecause in that context it doesn't matter if its a clone or not.
Because if both are equal why bother incrementing c. ?
This is not that important though I am just nitpicking.
Given the hidden constant factor in your function getMax (cloning the array and the hidden constant factor in building a max heap). Its its better doingto do it the straightforward way:
You iterate over n/2 floor elements (no leaf elements). So only by that you know is at least O(n). The function called buildMaxHeap is actually O(h) worst case, h being the height of the node (which you call i) in the heap. So because the height of any heap is http://latex.codecogs.com/gif.latex?%5Cleft&space;%5Clfloor&space;lg&space;n&space;%5Cright&space;%5Crfloor
buildMaxHeap doesn't actually builds the max heap so it shouldn't be named as it did. This function is commonly called maxheapify and is to maintain the heap property. Also I would change the name of parameter clone for something more generic, since in that context it doesn't matter if its a clone or not.
Because if both are equal why bother incrementing c. This is not that important though I am just nitpicking.
Given the hidden constant factor in your function getMax (cloning the array and the hidden constant factor in building a max heap). Its better doing it the straightforward way:
You iterate over http://latex.codecogs.com/gif.latex?%5Cleft&space;%5Clfloor&space;n/2&space;%5Cright&space;%5Crfloor elements (no leaf elements). Knowing this we can conclude that is at least O(n). The function called buildMaxHeap is actually O(h), h being the height of the node (which you call i). So because the height of any heap is http://latex.codecogs.com/gif.latex?%5Cleft&space;%5Clfloor&space;lg&space;n&space;%5Cright&space;%5Crfloor
buildMaxHeap doesn't actually builds the max heap so it name is not appropriate. This function is commonly called maxheapify and is to maintain the heap property. Also I would change the name of parameter named clone for something more generic, because in that context it doesn't matter if its a clone or not.
Because if both are equal why bother incrementing c ?
This is not that important though I am just nitpicking.
Given the hidden constant factor in your function getMax (cloning the array and the hidden constant factor in building a max heap) its better to do it the straightforward way: