then the rearrangement algorithm starts by bubbling down [ / [ which turns out not to be necessaryso the array remains the same next [ is bubbled downswapping with [ giving next [ is bubbled downswapping with [ giving finallya[ is bubbled downswapping with [ to give first then swapping with [ to give and finally swapping with [ to give which has the array rearranged as the required heap tree thususing the above bubbledown procedurethe algorithm to build complete binary heap tree from any given array of size is simplyheapify(array aint nfori / -bubbledown( , ,nthe time complexity of this heap tree creation algorithm might be computed as followsit potentially bubbles down bn/ itemsnamely those with indices bn/ the maximum number of bubble down steps for each of those items is the height of the treewhich is log nand each step involves two comparisons one to find the highest priority child nodeand one to compare the item with that child node so the total number of comparisons involved is at most ( / log nlog nwhich is the same as we would have by inserting the array items one at time into an initially empty tree in factthis is good example of situation in which naive counting of loops and tree heights over-estimates the time complexity this is because the number of bubble down steps