Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
配列のすべての要素、つまり[19 18 14 15 5 7 13 3 8]が降順ではないように、配列の要素をソートするためのヒープソートのアルゴリズムが必要です。
ヒープソート については、こちらをご覧ください。素敵な疑似コードも提供されています。
ヒープソートは非常に単純です。すべての要素を取得し、任意の順序でヒープ (この場合は max-heap) に配置し、ヒープから (delete-max 操作を使用して) 取得すると、すべてが並べ替えられます。
実はIFフリー(ブランチレス)のヒープソートが使える