当前位置:网站首页>Mirror image of binary tree
Mirror image of binary tree
2022-06-25 05:21:00 【Don't hit me, it hurts!】
subject

[ Simple 、 recursive ]
Answer key
The left and right subtrees of a commutative binary tree
function Mirror( pRoot ) {
// Recursive export
if(pRoot === null){
return pRoot;
} else {
[pRoot.left,pRoot.right] = [pRoot.right,pRoot.left]
}
Mirror(pRoot.left);
Mirror(pRoot.right);
return pRoot;
}
Supplementary knowledge
Answer template of binary tree
function traverse(TreeNode root){
// The former sequence traversal
traverse(root.left)
// In the sequence traversal
traverse(root.right)
// After the sequence traversal
}
The central idea of recursion :
- Consider exporting ( if part )
- Process the current node
- Recursively process the next node
Recursive exit of binary tree problem , Generally include :
// 1. Node is empty ( To the leaf node )
pRoot === null
The article links : Image of binary tree [ The finger of the sword offer]
* Please quote from QW’s Blog!*
边栏推荐
- 1.5.3 use tcpdump to observe ARP communication process
- JS function to realize simple calculator
- Conflict between v-mode and v-decorator in Ant Design
- TX Text Control 30.0 ActiveX
- Swift rapid development
- Deep analysis of recursion in quick sorting
- Creation and use of MySQL index
- CTFHub-rce
- ThinkPHP 5 log management
- Two dimensional array and function call cases of C language
猜你喜欢

Small sample learning data set

Two hours to take you into the software testing industry (with a full set of software testing learning routes)
![[relax's law of life lying on the square] those poisonous chicken soup that seem to be too light and too heavy, but think carefully and fear](/img/12/d41f8d5abcb61d2632a8b117bf1604.jpg)
[relax's law of life lying on the square] those poisonous chicken soup that seem to be too light and too heavy, but think carefully and fear

Detailed summary of flex layout

Penetration test - right raising topic

Uva1103 ancient pictograph recognition

Essais de pénétration - sujets d'autorisation
![H5 canvas drawing circle drawing fillet [detailed explanation]](/img/6f/a33a323b6cd0918066e8b71a22d841.jpg)
H5 canvas drawing circle drawing fillet [detailed explanation]

Five simple data types of JS

hr竟主动给这位测试小姐姐涨工资,她是怎么做到的?
随机推荐
Notes on non replacement elements in the line (padding, margin, and border)
Penetration test - right raising topic
Electronic Society C language level 1 28, character diamond
投资理财产品的年限要如何选?
C language -- Sanzi chess
CTFHUB SSRF
Install pytorch through pip to solve the problem that torch cannot be used in jupyter notebook (modulenotfoundererror:no module named 'Torch').
Duplicate symbols for architecture i386 clang
JS handwriting depth clone array and object
Two hours to take you into the software testing industry (with a full set of software testing learning routes)
Enhanced paste quill editor
Vue uses keep alive to cache page optimization projects
Mobile number regular expression input box loses focus verification
Deeply understand the characteristics of standard flow and off standard elements
Mysql interactive_ Timeout and wait_ Timeout differences
Use js to simply implement the apply, call and bind methods
Double recursion in deep analysis merge sort
File upload vulnerability (III)
Eyeshot Ultimate 2022 Crack By Xacker
2021-10-24