Source Code:https://thecodingsimplified.com/connect-next-pointer-to-its-inorder-successor-in-binary-tree/
Solution:
- We traverse the binary tree in inorder manner
- We take a global variable 'prev'
- Now whenever we're traversing any node, we point 'next' pointer of previous to the current node
- After each iteration we update the prev to current node
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 - 73: Connect ‘next’ pointer to it’s Inorder Successor in Binary Tree | NatokHD