Рет қаралды 7,587
This is the video under the series of DATA STRUCTURE & ALGORITHM in a TREE Playlist. We are going to understand How to Populating Next Right Pointers in Each Node.
Join My Telegram channel for more Updates: telegram.me/he...
complete DSA preparation: github.com/Pri...
► 116. Populating Next Right Pointers in Each Node
You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:
struct Node {
int val;
Node *left;
Node *right;
Node *next;
}
Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL.
Initially, all next pointers are set to NULL.
Input: root = [1,2,3,4,5,6,7]
Output: [1,#,2,3,#,4,5,6,7,#]
Explanation: Given the above perfect binary tree (Figure A), your function should populate each next pointer to point to its next right node, just like in Figure B. The serialized output is in level order as connected by the next pointers, with '#' signifying the end of each level.
We also Provide courses on Competitive Programming and Data structure and Algorithms. Please see our Full Playlist on our Channel.
----------------------------------------------------------------------------------------:
Populating Next Right Pointers in Each Node: leetcode.com/p...
code in This Video: github.com/Pri...
----------------------------------------------------------------------------------------
** Unacademy
Use my code "HELLOWORLD" to get 10% discount
Career as a Developer: unacademy.com/...
Tech Extracurriculars: bit.ly/Unacade...
----------------------------------------------------------------------------------------
*Follow me *
LinkedIn► / iamprince
Facebook► / helloworldofficials
Instagram► / helloworldbyprince
Twitter► / prince_king_
Telegram► telegram.me/he...
----------------------------------------------------------------------------------------
►Our Playlists on:-
► Tree: • Tree Data Structure & ...
► Hashing: • Hashing Data Structure...
► Matrix: • Matrix (Multidimension...
► STL: • Standard Template Libr...
► Leetcode: • LeetCode Solutions And...
►Competitive Programming: • Full course in Competi...
►C++ Full Course : • C++ full Course in HINDI
►Algorithms: • L-01 || Prefix Sum Arr...
►Data Structure: • Data Structures with C...
------------------------------------------------------------------------
🌟 Please leave a LIKE ❤️ and SUBSCRIBE for more AMAZING content! 🌟
✨ Tags ✨
Populating Next Right Pointers in Each Node
perfect binary tree
The tree Data structure in Hindi
Find the Invert of a Binary Tree
Use of Tree Data structure in real Life
question asked in Google
off-campus placement
how to learn to code for beginners
Practice Tree data structure
tree in data structure
Best Telegram channel for Off-campus Placement drive
Tree in a data structure in Hindi
Tree Full playlist for Beginners
#Tree #Leetcode #programming