Populating Next Right Pointers in Each Node | BFS Python

Published: 23 January 2022
on channel: Emily Bao
52
1

Link to question:
https://leetcode.com/problems/populat...

The last node in the level is len(queue)-1 because python is 0 indexed language. Queue starts with index 0.

Time: O(N) → we process each node exactly once
Space: O(N) → This is a perfect binary tree which means the last level contains N/2 nodes. The space complexity for BFS is the space occupied by the queue which is dependent upon the maximum number of nodes in a particular level. The upper bound on space if it is a regular tree is O(N).


On this page of the site you can watch the video online Populating Next Right Pointers in Each Node | BFS Python with a duration of hours minute second in good quality, which was uploaded by the user Emily Bao 23 January 2022, share the link with friends and acquaintances, this video has already been watched 52 times on youtube and it was liked by 1 viewers. Enjoy your viewing!