| |

VerySource

 Forgot password?
 Register
Search
Author: aresyt

Ask: How to find the rightmost node of the last layer of a complete binary tree

[Copy link]

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-16 19:27:02
| Show all posts
Yes, breadth traversal
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-18 13:27:01
| Show all posts
I think about it this way:
Queue-based breadth-first traversal is used. Each time a visited node is popped from the queue into the stack, the data item at the top of the stack after the traversal is requested.
The complexity of this algorithm is indeed much greater than that of array-based ones.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-18 23:09:01
| Show all posts
Is it OK to go down by layers?
Reply

Use magic Report

0

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-20 11:45:01
| Show all posts
Hierarchical traversal and breadth-first methods are the same.
Reply

Use magic Report

0

Threads

17

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

Post time: 2020-1-29 17:09:01
| Show all posts
It is also possible to traverse first or in the middle.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list