翻訳と辞書
Words near each other
・ Heap Steep Glacier
・ Heap's algorithm
・ Heap's Rice Mill
・ Heap, Bury
・ Heapey
・ Heapey railway station
・ Heapham
・ Heaphy
・ Heaphy River
・ Heaphy Spur
・ Heaphy Tin Man
・ Heaphy Track
・ Heaps (surname)
・ Heaps Rock
・ Heaps' law
Heapsort
・ Hear & Now
・ Hear & Now (Billy Squier album)
・ Hear & Now (Don Cherry album)
・ Hear 'Em Rave
・ Hear 'n Aid
・ Hear (Diesel album)
・ Hear (disambiguation)
・ Hear and Now
・ Hear and Now (album)
・ Hear in the Now Frontier
・ Hear It Is
・ Hear It Now
・ Hear Me
・ Hear Me (EP)


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Heapsort : ウィキペディア英語版
Heapsort

In computer science, heapsort is a comparison-based sorting algorithm. Heapsort can be thought of as an improved selection sort: like that algorithm, it divides its input into a sorted and an unsorted region, and it iteratively shrinks the unsorted region by extracting the largest element and moving that to the sorted region. The improvement consists of the use of a heap data structure rather than a linear-time search to find the maximum.
Although somewhat slower in practice on most machines than a well-implemented quicksort, it has the advantage of a more favorable worst-case O(''n'' log ''n'') runtime. Heapsort is an in-place algorithm, but it is not a stable sort.
Heapsort was invented by J. W. J. Williams in 1964. This was also the birth of the heap, presented already by Williams as a useful data structure in its own right. In the same year, R. W. Floyd published an improved version that could sort an array in-place, continuing his earlier research into the treesort algorithm.〔
== Overview ==
The heapsort algorithm can be divided into two parts.
In the first step, a heap is built out of the data. The heap is often placed in an array with the layout of a complete binary tree. The complete binary tree maps the binary tree structure into the array indices; each array index represents a node; the index of the node's parent, left child branch, or right child branch are simple expressions. For a zero-based array, the root node is stored at index 0; if i is the index of the current node, then

iParent = floor((i-1) / 2)
iLeftChild = 2
*i + 1
iRightChild = 2
*i + 2

In the second step, a sorted array is created by repeatedly removing the largest element from the heap (the root of the heap), and inserting it into the array. The heap is updated after each removal to maintain the heap. Once all objects have been removed from the heap, the result is a sorted array.
Heapsort can be performed in place. The array can be split into two parts, the sorted array and the heap. The storage of heaps as arrays is diagrammed here. The heap's invariant is preserved after each extraction, so the only cost is that of extraction.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Heapsort」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.