当前位置:网站首页>Binary tree - right view
Binary tree - right view
2022-06-13 00:49:00 【Feiyichai】
Question source :LeetCode
- Problem description

- Algorithmic thought
The node seen from the right must be the last node of each layer , Therefore, using hierarchical traversal , Find the last node of each layer
void rightElevation(BiTree T){
if(!T) return null;
BiTree Q[MAXSISE],temp[MAXSIZE];
int rear=-1,front=-1,last=0;
TNode *p;
int i=0;
while(rear>front){
Q[++front]=p;
if(p->lchild) Q[++rear]=p->lchild;
if(p->rchild) Q[++rear]=p->rchild;
if(last==front){
temp[i++]=p;
last = rear;
}
}
for(int j=0;j++) print(temp[i]);
}
边栏推荐
- Browser console injection JS
- Four startup modes of kotlin collaboration
- [Error] invalid use of incomplete type 使用了未定义的类型
- Using fastjson to solve the problem of returning an empty array from a null value of a field string object
- Development notes of Mongoose
- [JS component] custom paging
- [North Asia server data recovery] data recovery case of Hyper-V service paralysis caused by virtual machine file loss
- Canvas game lower level 100
- Cards are unpredictable
- 生物解锁--指纹录入流程
猜你喜欢
![BUUCTF之BabyUpload[GXYCTF2019]](/img/e8/202298b64d8764355fad348b50fee6.png)
BUUCTF之BabyUpload[GXYCTF2019]
![[JS] battle chess](/img/1f/83ca6bcb000a5567dc6d3b72463ff8.jpg)
[JS] battle chess

How to solve the duplication problem when MySQL inserts data in batches?

市值破万亿,连续三个月销量破10万,比亚迪会成为最强国产品牌?

人神共愤,唐山“群殴女性事件”细节...
![[gxyctf2019] no dolls -- detailed explanation](/img/c8/8c588ab8f58e2b38b9c64c4ccd733f.png)
[gxyctf2019] no dolls -- detailed explanation

Four startup modes of kotlin collaboration

What is meebits? A brief explanation

Kali system -- host, dig, dnsenum, imtry for DNS collection and analysis
![[JS component] floating text](/img/e5/7faad5422bba919bed34e3dbcf7ba0.jpg)
[JS component] floating text
随机推荐
Lambda expression
Download nail live playback through packet capturing
[GYCTF2020]Ezsqli --BUUCTF
A simple deadlock example
Kalix system - use of information collection gadgets
pytorch是什么?解释pytorch的基本概念
[CISCN2019 华北赛区 Day2 Web1]Hack World --BUUCTF
Influence of higher order poles on waveform
[ciscn2019 North China Day2 web1]hack world --buuctf
Androi天气
[Error] invalid use of incomplete type 使用了未定义的类型
Penetration test summary
[North Asia server data recovery] data recovery case of Hyper-V service paralysis caused by virtual machine file loss
[JS] solve the problem that removeeventlistener is invalid after the class listening event from new is bound to this
草在结种子了
Arduino controls tb6600 driver +42 stepper motor
Easyexcel read excel simple demo
Notes: the 11th and 12th generation mobile versions of Intel support the native thunderbolt4 interface, but the desktop version does not
Make the tasks in the scheduled task XXL job flexible
Kotlin collaboration, the life cycle of a job