Back to Browse

Binary Tree - 75: Connect Nodes at same Level with 'next' pointer

8.7K views
Jan 21, 2020
25:44

Source Code:https://thecodingsimplified.com/connect-nodes-at-same-level-with-next-pointer/ Solution - 1: - We do level order traversal & maintain a previous node - At starting of every level, we set previous to null - While traversing a npde, we point next of previous to current node Time Complexity: O(n) Space Complexity: O(n) Solution - 2: - We traverse the binary tree in pre-order manner - We keep on adding the next pointer for a level Time Complexity: O(n) Space Complexity: O(1) Do Watch video for more info CHECK OUT CODING SIMPLIFIED https://www.youtube.com/codingsimplified ★☆★ VIEW THE BLOG POST: ★☆★ http://thecodingsimplified.com I started my YouTube channel, Coding Simplified, during Dec of 2015. Since then, I've published over 200+ videos. ★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★ https://www.youtube.com/codingsimplified?sub_confirmation=1 ★☆★ Send us mail at: ★☆★ Email: [email protected]

Download

0 formats

No download links available.

Binary Tree - 75: Connect Nodes at same Level with 'next' pointer | NatokHD