Min Li's Note
KVM,QEMU, X86 virtualization
Pages
Home
Collection
About
Monday, September 29, 2014
Populating Next Right Pointers in Each Node
Problem
Too long. Check the 传送们:
Idea
完全binary tree节点数n和层数h的关系
n = 2^(h)-1; (h从1开始)
先把每一层的最右边的next = NULL设置好,然后遍历每一层,起点是每层最左边的点,遍历每个点,把这个点下面的左孩子和右孩子连起来,然后再遍历一次,把不是同一个parent的两个相邻点连起来
Solution
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment