文件名称:SelectionSort
介绍说明--下载内容均来自于网络,请自行研究使用
选择排序:
分为直接选择排序, 堆排序
直接选择排序:第i次选取 i到array.Length-1中间最小的值放在i位置。
堆排序:首先,数组里面用层次遍历的顺序放一棵完全二叉树。从最后一个非终端结点往前面调整,直到到达根结点,这个时候除根节点以外的所有非终端节点都已经满足堆得条件了,于是需要调整根节点使得整个树满足堆得条件,于是从根节点开始,沿着它的儿子们往下面走(最大堆沿着最大的儿子走,最小堆沿着最小的儿子走)。 主程序里面,首先从最后一个非终端节点开始调整到根也调整完,形成一个heap, 然后将heap的根放到后面去(即:每次的树大小会变化,但是 root都是在1的位置,以方便计算儿子们的index,所以如果需要升序排列,则要逐步大顶堆。因为根节点被一个个放在后面去了。 降序排列则要建立小顶堆)-Select Sort:
Divided into direct selection sort, heap sort
Direct selection Sort by: i select i to array.Length the middle of the smallest value in the position i.
Heap sort: First, the traversal order of the array inside the level to put a complete binary tree. From the last non-terminal node Wang Qianmian adjustment, until it reaches the root node, this time other than the root node non-terminal node have met the condition of the heap, so the need to adjust the root node makes the whole tree to meet the conditions of the heap, so root node along its sons go to the following (maximum heap walking along the eldest son, the minimum heap walking along the youngest son). Inside the main program, first began to adjust from a non-terminal node to the root After adjustment, to form a heap, then the root of the heap on the back (ie: each tree size will change, but the root is in position to facilitate the calculation of the index of the sons, so if necessary, in ascending order, they
分为直接选择排序, 堆排序
直接选择排序:第i次选取 i到array.Length-1中间最小的值放在i位置。
堆排序:首先,数组里面用层次遍历的顺序放一棵完全二叉树。从最后一个非终端结点往前面调整,直到到达根结点,这个时候除根节点以外的所有非终端节点都已经满足堆得条件了,于是需要调整根节点使得整个树满足堆得条件,于是从根节点开始,沿着它的儿子们往下面走(最大堆沿着最大的儿子走,最小堆沿着最小的儿子走)。 主程序里面,首先从最后一个非终端节点开始调整到根也调整完,形成一个heap, 然后将heap的根放到后面去(即:每次的树大小会变化,但是 root都是在1的位置,以方便计算儿子们的index,所以如果需要升序排列,则要逐步大顶堆。因为根节点被一个个放在后面去了。 降序排列则要建立小顶堆)-Select Sort:
Divided into direct selection sort, heap sort
Direct selection Sort by: i select i to array.Length the middle of the smallest value in the position i.
Heap sort: First, the traversal order of the array inside the level to put a complete binary tree. From the last non-terminal node Wang Qianmian adjustment, until it reaches the root node, this time other than the root node non-terminal node have met the condition of the heap, so the need to adjust the root node makes the whole tree to meet the conditions of the heap, so root node along its sons go to the following (maximum heap walking along the eldest son, the minimum heap walking along the youngest son). Inside the main program, first began to adjust from a non-terminal node to the root After adjustment, to form a heap, then the root of the heap on the back (ie: each tree size will change, but the root is in position to facilitate the calculation of the index of the sons, so if necessary, in ascending order, they
(系统自动生成,下载前可以参看下载内容)
下载文件列表
SelectionSort.java