当前位置:网站首页>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
边栏推荐
- [combinatorics] permutation and combination (multiple set permutation | multiple set full permutation | multiple set incomplete permutation all elements have a repetition greater than the permutation
- Sitescms v3.1.0 release, launch wechat applet
- Seven second order ladrc-pll structure design of active disturbance rejection controller
- Cache penetration and bloom filter
- Sword finger offer 14- I. cut rope
- C graphical tutorial (Fourth Edition)_ Chapter 17 generic: genericsamplep315
- 【数据库原理及应用教程(第4版|微课版)陈志泊】【第七章习题】
- Quick learning 1.8 front and rear interfaces
- Xctf mobile--app3 problem solving
- Sword finger offer 12 Path in matrix
猜你喜欢
[ArcGIS user defined script tool] vector file generates expanded rectangular face elements
The upward and downward transformation of polymorphism
Grid connection - Analysis of low voltage ride through and island coexistence
如何在微信小程序中获取用户位置?
Analysis of a music player Login Protocol
有限状态机FSM
initial、inherit、unset、revert和all的区别
sitesCMS v3.1.0发布,上线微信小程序
Harmonic current detection based on synchronous coordinate transformation
Xctf mobile--app2 problem solving
随机推荐
Mysqlbetween implementation selects the data range between two values
SSH login server sends a reminder
Solve system has not been booted with SYSTEMd as init system (PID 1) Can‘t operate.
Tianyi ty1208-z brush machine detailed tutorial (free to remove)
低代码平台国际化多语言(i18n)技术方案
4. Wireless in vivo nano network: electromagnetic propagation model and key points of sensor deployment
How to get user location in wechat applet?
Node.js: express + MySQL的使用
我的创作纪念日:五周年
Enable SASL authentication for memcached
Seven habits of highly effective people
How to convert a decimal number to binary in swift
Openstack node address change
剑指 Offer 16. 数值的整数次方
Glide question you cannot start a load for a destroyed activity
Sword finger offer 16 Integer power of numeric value
有限状态机FSM
alright alright alright
2022-02-11 practice of using freetsdb to build an influxdb cluster
2022-02-10 introduction to the design of incluxdb storage engine TSM