BUILD-HEAP(A) heapsize := size(A); for i := floor(heapsize/2) downto 1 do HEAPIFY(A, i); end for END
What is the worst case time complexity of the above algo?
Although the worst case complexity looks like O(nLogn), upper bound of time complexity is O(n). See following links for the proof of time complexity.
http://www.cse.iitk.ac.in/users/sbaswana/Courses/ESO211/heap.pdf/
http://www.cs.sfu.ca/CourseCentral/307/petra/2009/SLN_2.pdf
Read full article from Time Complexity of building a heap | GeeksforGeeks
No comments:
Post a Comment