当前位置:网站首页>2022-02-11 heap sorting and recursion
2022-02-11 heap sorting and recursion
2022-07-03 13:04:00 【a tracer】
Abstract :
Record the experience when sorting the research reactor .
Heap sort :
Heap sorting is also a sort based on comparison , But its ideological basis comes from recursion , This is very significantly different from the idea of partition .
As a classic embodiment of recursive thought , It is necessary to draw lessons from the process of heap sorting .
Pseudo code for heap sorting :
CLRS
End of recursion , The key point is in the eighth line , Only when the subscript of the found maximum value is not itself , Before continuing recursion .
If you are the largest between yourself and the left node and the right node , Then recursion stops .
need MAX-HEAPIFY Only for a single node , Not the whole heap , So recursive calls are needed for the whole heap MAX-HEAPIFY
TAOCP This is the process in
Heap sort analysis :
Think about it as a whole , Then heap sorting can be abstracted into , A node , Dealing with the relationship between its left node and right node .
Start from the top , Then each point and its left and right nodes are processed recursively .
Consider starting from the top , Then pile top node , It is limited to the smallest data node of the whole heap
-> The heap top must be smaller than its left and right child nodes .
-> The left and right child nodes of the heap top , It must be smaller than the left and right child nodes of the corresponding node
边栏推荐
- 【数据挖掘复习题】
- 4. Wireless in vivo nano network: electromagnetic propagation model and key points of sensor deployment
- 剑指 Offer 12. 矩阵中的路径
- [Exercice 5] [principe de la base de données]
- SSH login server sends a reminder
- Four problems and isolation level of MySQL concurrency
- C graphical tutorial (Fourth Edition)_ Chapter 13 entrustment: what is entrustment? P238
- Application of ncnn neural network computing framework in orange school orangepi 3 lts development board
- 正则表达式
- 2022-01-27 redis cluster brain crack problem analysis
猜你喜欢
对业务的一些思考
IDEA 全文搜索快捷键Ctr+Shift+F失效问题
我的创作纪念日:五周年
[combinatorics] permutation and combination (the combination number of multiple sets | the repetition of all elements is greater than the combination number | the derivation of the combination number
[data mining review questions]
【Colab】【使用外部数据的7种方法】
Node. Js: use of express + MySQL
Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)
【计网】第三章 数据链路层(2)流量控制与可靠传输、停止等待协议、后退N帧协议(GBN)、选择重传协议(SR)
Sitescms v3.1.0 release, launch wechat applet
随机推荐
Leetcode234 palindrome linked list
[exercise 5] [Database Principle]
C graphical tutorial (Fourth Edition)_ Chapter 13 entrustment: what is entrustment? P238
ncnn神经网络计算框架在香橙派OrangePi 3 LTS开发板中的使用介绍
Exploration of sqoop1.4.4 native incremental import feature
It feels great to know you learned something, isn‘t it?
[comprehensive question] [Database Principle]
01 three solutions to knapsack problem (greedy dynamic programming branch gauge)
并网-低电压穿越与孤岛并存分析
initial、inherit、unset、revert和all的区别
How to convert a decimal number to binary in swift
【数据库原理及应用教程(第4版|微课版)陈志泊】【第五章习题】
The foreground uses RSA asymmetric security to encrypt user information
4. Wireless in vivo nano network: electromagnetic propagation model and key points of sensor deployment
剑指 Offer 14- II. 剪绳子 II
Some thoughts on business
Method overloading and rewriting
【R】【密度聚类、层次聚类、期望最大化聚类】
【数据库原理及应用教程(第4版|微课版)陈志泊】【第四章习题】
Mysqlbetween implementation selects the data range between two values