Determine if Two Trees are Identical | Same Tree l Tree Data Structure playlist C++ | Hello World

  Рет қаралды 10,943

Hello World

Hello World

Күн бұрын

This is the video under the series of DATA STRUCTURE & ALGORITHM in a TREE Playlist. We are going to understand How to Determine if Two Trees are Identical. We understand the Recursive code of the same Tree step by step.
Join My Telegram channel for more Updates: telegram.me/he...
100. Same Tree | Determine if Two Trees are Identical
Given the roots of two binary trees p and q, write a function to check if they are the same or not.
Input: p = [1,2,3], q = [1,2,3]
Output: true
We also Provide courses on Competitive Programming and Data structure and Algorithms. Please see our Full Playlist on our Channel.
----------------------------------------------------------------------------------------
Same Tree: leetcode.com/p...
Determine if Two Trees are Identical: practice.geeks...
code in This Video: github.com/Pri...
----------------------------------------------------------------------------------------
*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 ✨
Determine if Two Trees are Identical
What is Tree Data Structure in Hindi
What is Inorder, Preorder & Postorder
Code of Binary tree in c++
Use of Tree Data structure in real Life
question asked in Google
how to crack Google Interview
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

Пікірлер: 77
@rdxgaurav3483
@rdxgaurav3483 2 жыл бұрын
Most satisfactory answers , Thanks a lot, the way you speak , its so humble , you made complex things easier , your dry runs and all, anyone else couldn't do this ,Please keep it up and keep making videos on more problems
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 жыл бұрын
bro , inorder postorder se bhi hoskta hai ??
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
@shaantyagi2187
@shaantyagi2187 2 жыл бұрын
Maja aa gya bhaiya ........baaki channels pe maine observe kiya hai ki sab bus concept samjha rahe hai but ...iss tarah ke questions itna acche se koi nahi samjha raha .....ek dum baith gya dimaag main
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
Thanks a lot buddy Please, if possible then share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
@UnKnown-id7ih
@UnKnown-id7ih 2 жыл бұрын
Bhiya aapse hme bahot kuch shikhna chiya jaise ki aap views kam aate hai phir bhi aap hamare liye video banate hai aur mehanat krte h. waise main java mai code krta hu phir bhi smjh aata hai. Thank you Bhiya for everything.
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
Thanks bhai Bass share kardo channel ko aap mere motivation ke liye 🥰
@UnKnown-id7ih
@UnKnown-id7ih 2 жыл бұрын
@@HelloWorldbyprince friends group mai share kr diya
@nitishkumarsingh1980
@nitishkumarsingh1980 2 жыл бұрын
" bahut asaan hai "ye line sunke bahut motivation milta hai
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Hahahah thanks
@abhishekrai3
@abhishekrai3 Жыл бұрын
bhaiya, really mai tree ke questions me bahot problem face kr rha tha, but apke samjhane ka tarika and question ko kaise approach kare ye samjhane ka tarika bahot hi unique hai dheere dheere confidence build ho rha, thank you bhaiya for a wonderful playlist ❤❤❤❤❤❤
@codemachine7381
@codemachine7381 2 жыл бұрын
This is some teaching.. That's called what we say in depth conceptual understanding.
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Thanka a lot mannn
@AnkitKumar-oz6wl
@AnkitKumar-oz6wl 2 жыл бұрын
Bhaiya mei first baar mei recursive approach hee socha tha but implement nahi kar pa raha tha kyunki abhi tak recursion nahi padha hai. Acha laga bhaiya.
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Yesss, keep learning buddy thanks for sharing your thoughts
@swatisinha5037
@swatisinha5037 10 ай бұрын
forget other people you are a gem fr i mean your teaching stlye is og
@ShubhamKumar-ex3nk
@ShubhamKumar-ex3nk 2 жыл бұрын
bool isSameTree(TreeNode* p, TreeNode* q) { if(!p and !q) return true; if((!p or !q)) return false; if(p->val != q->val) return false; return isSameTree(p->left,q->left) and isSameTree(p->right,q->right); }
@splendidabhi
@splendidabhi 3 жыл бұрын
Thankyou 🙏🙏
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
Thanks Abhinav for supporting me
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 жыл бұрын
bhaiya , inorder and preorder traversal me stack use karte hai .. lekin isme use q nahi kiya ?
@zaidshaikh8111
@zaidshaikh8111 2 жыл бұрын
if we are inserting NULL to fir do traversal check karne ki zarurat nahi hai bhaiya. ek se kam ho jayega. kyuki same elements bhi hai to bhi NULL to alag jaga hi hoga na.
@beckygray2543
@beckygray2543 Жыл бұрын
didnt get you..can you elaborate a bit?
@devu5501
@devu5501 4 ай бұрын
It’s too good explaination than love babbar and striver really
@nisargbarot1998
@nisargbarot1998 Жыл бұрын
Superb!!! Itna detail me kisi ne nai samjhaya code
@jdn9717
@jdn9717 Жыл бұрын
Thank you sir
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
your welcome
@abhineetsingh6720
@abhineetsingh6720 2 жыл бұрын
nice, learnt something new today. If 2 traversals are same, then trees will be same
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
good keep learning
@beckygray2543
@beckygray2543 Жыл бұрын
hello! loving your videos. i think there's a small error at 6:13...since looks like you've constructed a tree from the values using preorder, the tree should look smthg like...pls crct me if im wrong 1 / \ 2 4 / \ null 3
@ADISHVAR1
@ADISHVAR1 Жыл бұрын
thanku sir
@user-mn4tb3lw3k
@user-mn4tb3lw3k Жыл бұрын
very easy and sorted explanation...Keep up the good work :)
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Thanks, will do!
@MANISHKUMAR-vn1yh
@MANISHKUMAR-vn1yh 2 жыл бұрын
thanks dude
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
Your most welcome 😁
@shivangisingh1988
@shivangisingh1988 2 жыл бұрын
sundarrrr explanation😍😍😍😍
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
Thank you 🙂
@jatilyadav4000
@jatilyadav4000 Жыл бұрын
great teaching prince sir
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Thanks and welcome
@hemantkumar2585
@hemantkumar2585 2 жыл бұрын
thankyou bhaiya
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
welcome buddy
@cr7johnChan
@cr7johnChan 2 жыл бұрын
Thank you for bringing quality content!! Did it on my own!!!
@shubhambhosale8467
@shubhambhosale8467 2 жыл бұрын
in approach 2 we are checking only data left and right what about left left? plz comment sir
@cr7johnChan
@cr7johnChan 2 жыл бұрын
@@shubhambhosale8467 bool isSameTree(TreeNode* p, TreeNode* q) { if(p==NULL && q!=NULL)return false; if(p!=NULL && q==NULL)return false; if(p!=NULL && q!=NULL){ if(!isSameTree(p->left,q->left))return false; if(p->val!=q->val)return false; if(!isSameTree(p->right,q->right))return false; } return true; } yeh lo mera solution ,meh har node ko ek sath check karte jaa raha hoon. Suppose p->left is compared with q->left simultaneously ,same for other nodes through recursion. Aur agar kuch match nahi kya toh false return kar raha hoon, agar agar true hai toh pura tree traverse kar raha hoon
@cr7johnChan
@cr7johnChan 2 жыл бұрын
@@shubhambhosale8467 for more u can also go through Prince Bhai Graph Series ,because dfs ,bfs and recursion are taught very well, do two rounds of that playlist ,and u r good to go with trees.
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
Any time!
@shubhambhosale8467
@shubhambhosale8467 2 жыл бұрын
sir explain this part
@RIyaGupta-iz9iw
@RIyaGupta-iz9iw 5 ай бұрын
Sir space complexity kya hogi
@BAkashAnand
@BAkashAnand Жыл бұрын
What is the difference between your code and mine? I cant find any but this code shows an error while running if(root==NULL) { v.push_back(100000); } preOrder(root->left,v); v.push_back(root->val); preOrder(root->right,v);
@iitimunda
@iitimunda Жыл бұрын
if you are doing PreOrder then it is node left right
@sujeet9889
@sujeet9889 3 жыл бұрын
Bhaiya tree ke playlist me to 17 videos hai wo bhi arrange nahi hai
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
Ab arrange kar diye
@sujeet9889
@sujeet9889 3 жыл бұрын
@@HelloWorldbyprince thank you bhaiya
@jyotikhot7269
@jyotikhot7269 3 жыл бұрын
Sb clear h...😃😄❤️
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
wahh good work Jyoti
@alexmercer5870
@alexmercer5870 3 жыл бұрын
thanks prince bhaiii 🚀
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
Your welcome buddy
@sohebshaikh3344
@sohebshaikh3344 3 жыл бұрын
Ha bhai socha tha code run bhi hua sahi lekin accpet nhi ho rha tha
@shivduttjha3502
@shivduttjha3502 3 жыл бұрын
♥️♥️♥️
@BrajeshKumar-ve1kd
@BrajeshKumar-ve1kd 2 жыл бұрын
Sir muse ek captcha entry jobs banadajie
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
Okay if I will find something regarding u I will message u
@asurstark
@asurstark Жыл бұрын
Hello world >>>>>>>>>> Striver
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Hahah Thanks buddy
@jayeshnayee6735
@jayeshnayee6735 2 жыл бұрын
Gfg par accept nathi hotaa
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
why bro ? checked solution
@deepakpal3980
@deepakpal3980 Жыл бұрын
In first mathed case 60 are false.
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
why ?
@raushanraj6054
@raushanraj6054 3 жыл бұрын
Prince bhai adjust your audio according to your explanation. In this video , you are speaking something else and writing/explaining something else. If possible try to fix it
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
yaaa 😄 iss wale video me thora problem ho gya
@mohitarya5189
@mohitarya5189 7 ай бұрын
Thank you
@HelloWorldbyprince
@HelloWorldbyprince 7 ай бұрын
You're welcome
Люблю детей 💕💕💕🥰 #aminkavitaminka #aminokka #miminka #дети
00:24
Аминка Витаминка
Рет қаралды 1,2 МЛН
WILL IT BURST?
00:31
Natan por Aí
Рет қаралды 40 МЛН
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Codebagel
Рет қаралды 370 М.
Identical Binary Search Tree | C++ Placement Course | Lecture 28.8
16:09
Coding Interview | Software Engineer @ Bloomberg (Part 1)
30:05
Keep On Coding
Рет қаралды 4,6 МЛН
Check if two binary trees are identical (Algorithm/code/program)
7:34
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 27 М.