}
時(shí)間復(fù)雜度:
堆排序的時(shí)間復(fù)雜度是O(n lg(n));
max_heapify()函數(shù)的時(shí)間復(fù)雜度是O(n lgn);
建最大堆(Build_max_heap())的時(shí)間復(fù)雜度度為O(n);
排序過(guò)程要調(diào)用n次Build_max_heap()函數(shù)所以堆排序的時(shí)間復(fù)雜度是O(n lgn);
以上堆排序的時(shí)間復(fù)雜度的詳細(xì)推導(dǎo)過(guò)程參考《算法導(dǎo)論》第三版P85.
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注