Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What sort is heap sort

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

In this issue, the editor will bring you about the sort of heap. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Heap sorting is to generate a maximum heap from an unordered sequence, swap the top element of the heap with the last element, and generate the maximum heap of the remaining elements, exchange elements in turn and generate the sort of the largest heap.

Heap sort

The unordered sequence is generated into a maximum heap, the top element of the heap is swapped with the last element, the remaining elements are generated into the maximum heap, and the elements are exchanged in turn to generate the maximum heap.

Time complexity: O (NlogN) space complexity: O (1)

Brief introduction:

Heap sorting (English: Heapsort) refers to a sort algorithm designed by using the data structure of heap. The heap is a structure similar to a complete binary tree and satisfies the property of stacking at the same time, that is, the key value or index of a child node is always less than (or greater than) its parent node.

Operation of heap

In the data structure of the heap, the maximum value in the heap is always at the root node (if the heap is used in the priority queue, the minimum value in the heap is at the root node).

The following operations are defined in the heap:

Maximum heap adjustment (Max Heapify): adjust the terminal node of the heap so that the child node is always smaller than the parent node

Create maximum heap (Build Max Heap): reorder all data in the heap

Heap sort (HeapSort): a recursive operation that removes the root node of the first data and makes the maximum heap adjustment

The above is the sort of heap that the editor shares. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report