MCPcopy Create free account
hub / github.com/byhieg/JavaTutorial / heapSort

Method heapSort

src/main/java/cn/byhieg/algorithmtutorial/Sort.java:257–273  ·  view source on GitHub ↗

堆排序,建立一个小顶堆,小顶堆满足父节点比两个子节点的值要小 堆的性质满足:1. 只能在堆顶删除元素 2. 只能在堆的最后一位存元素。 3. 堆的存储利用数组,满足i节点是父节点,则子节点是2 i+ 1,2 i + 2 4. 堆的两种建方法,第一种是从上到下,@see sink(),第二种是从下到上 @see swim 5. 堆排序是指在弄好的堆中,输出第一个元素,然后将最后一个元素与第一个元素互换,换后调用sink,找到自己的位置后,在重复这个步骤,就输出一个有序的堆 6. 如果要生

(int[] nums)

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers

nothing calls this directly

Calls 1

sinkMethod · 0.95

Tested by

no test coverage detected