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

[ Simple 、 recursive ]
Answer key
Depth of tree = max( Left subtree depth , Right subtree depth )+1
function TreeDepth(pRoot)
{
// Recursive export
if(pRoot===null) return 0;
let left = TreeDepth(pRoot.left);
let right = TreeDepth(pRoot.right);
return 1 + (left>right?left:right);
}
And the method of hierarchical traversal , To be added ……
* Please quote from QW’s Blog!*
边栏推荐
- Route parameters to jump to the page and transfer parameters -- > hidden parameter list
- Dynamic programming full backpack
- Mysql interactive_ Timeout and wait_ Timeout differences
- Object creation and invocation code example
- 电子协会 C语言 1级 28 、字符菱形
- Bind simulation, key points of interpreting bind handwritten code [details]
- MySQL prevents Chinese garbled code and solves the problem of Chinese garbled code
- Database overview
- Large number operation (capable of square root, power, permutation and combination, logarithm and trigonometric value)
- JS function to realize simple calculator
猜你喜欢

Array and simple function encapsulation cases

Working principle of asemi three-phase rectifier bridge

TeeChart Pro ActiveX 2022.1

The article is on the list. Welcome to learn
![H5 canvas drawing circle drawing fillet [detailed explanation]](/img/6f/a33a323b6cd0918066e8b71a22d841.jpg)
H5 canvas drawing circle drawing fillet [detailed explanation]

Install pytorch through pip to solve the problem that torch cannot be used in jupyter notebook (modulenotfoundererror:no module named 'Torch').

In depth understanding of line height and vertical align

JSON Library Tutorial from scratch (I): starting to learn and organize notes

2022.1.21 diary

C language - minesweeping
随机推荐
Detailed summary of flex layout
Specific operations for uploading pictures in PHP
Laravel's little knowledge
parallel recovery slave next change & parallel recovery push change
For in JS Of and for in
Database low-end SQL query statement fragment
2021-10-24
PHP calls map API
Array: force deduction dichotomy
Database query optimization method
H5 native player [learn video]
Dynamic programming example 2 leetcode62 unique paths
Google Earth engine (GEE) - Global jrc/gsw1_ 1 / batch download of yearlyhistory dataset (China region)
1.6.3 use tcpdump to observe DNS communication process
Go Context - Cancelation and Propagation
TeeChart Pro ActiveX 2022.1
Array and simple function encapsulation cases
Ctfhub eggs
Stack and Queue
Detailed summary of float