whatever you teach just goes straight into my head , thanks for making me feel not dumb.
@pushkarraja49382 жыл бұрын
I bought a course from Coding Ninjas, I spent about 6000 on that and they have not even talked about iterative ways in the tree part. Thanks Striver bhai for making these high quality videos for free.
@joebale96702 жыл бұрын
haan sahi baat hai wo lavde paise khane bethe hain mc.
@vinayjangra14012 жыл бұрын
😅i am also from there! btw no one is prefect, jha se gyan mile lelo🙃
@abhigyanraha56202 жыл бұрын
Striver is absolutely insane. He is doing god's work IMO. The production quality, the clarity of concepts, the length of the videos, the depth of explanation and the concept coverage is absolutely mind-blowing. Techdose is another channel that explains every question in depth!
@lifehustlers164 Жыл бұрын
mujhe offer mein 4100 ka milgya tha but still trees mein confidence nhi aaya. But ig maine trees thoda rush kia tha ,islie mujhe nhi aaya ache se samjh , course to acha hai vo no doubt, it all depends on the efforts ig in the end !!! Well i am glad you also have bought it,where are u now?
@anubhaaav4 ай бұрын
@@lifehustlers164 where are you now?
@theSeniorSDE3 жыл бұрын
Striver, Day 2 : completed this as well.
@deepaksarvepalli23443 жыл бұрын
Felt bad... your work deserves more likes ...those who watched it, please like this..so that it will improves sir's interest
I don't know weather he is gifted, genius or really really hardworker. Anyways one thing is sure is a giver. Thanks Raj.
@shivangisrivastava11583 жыл бұрын
Very clearly explained! 👏 Just one thing, we can use root variable itself, instead of declaring 'node'. It still works! ( however no memory usage improvement on leetcode)
@_theCorporateMonk3 жыл бұрын
Exactly!
@Cool962673 жыл бұрын
In that case we'll lose the root of tree, which we may require for further work.
@saketmehta6697 Жыл бұрын
Modification of input ds is not at all recommended in interviews or real production env.
@IBMX6514 күн бұрын
@@_theCorporateMonk not a good practice brother
@PrashantSingh-jy6zp3 жыл бұрын
for skip promotion go to 0:43 code explanation at 8:49
@shubamgoswami3 жыл бұрын
most imp
@ishwaripednekar516410 ай бұрын
Hello Striver, You explain code very well. Thankyou for such kind of content.
@sangharshpipare6668 ай бұрын
Thanks for making concepts easy to understand
@lifehustlers164 Жыл бұрын
Completed 11/54(20% done) !!!
@AyushMishra-b8w7 ай бұрын
Everything is very much clear to me thanks a lot bro
@allinonep.94542 жыл бұрын
I first like the video then starts watching 🤩....! Because I know your videos are always amazing. Thank you so much for such a amazing series.
@adityajain51012 жыл бұрын
A gentle feedback : The explanation is Great but here you could have given more light on the statement that how we are making iterative solution from recursion inorder solution discussed before ..... you have told that this is taken from recursive but with more explanation I think But Thankyou for the amazing series
@chiraggaba_03011 ай бұрын
Love You Man..., You are the Lord for Techies.
@tanujamaurya887511 ай бұрын
Thank you Striver Bhaiya! for your efforts to make such great content !
@sukritinarang50162 жыл бұрын
Recursive and Iterative both approaches are clear !Thanks
@supriyakeshri783 күн бұрын
please start string series also.It will be very helpful
@apmotivationakashparmar722Ай бұрын
Thank you So much . Please Upload video Solutions of left Questions.
@ganeshjaggineni40974 ай бұрын
NICE SUPER EXCELLENT MOTIVATED
@shivalikagupta34332 жыл бұрын
Thank you soo much !!! Recursive and Iterative clearing both the approaches. :))))
@vineetjadhav17853 ай бұрын
Very Good Explaination❤❤🔥🔥
@gaikwadpratik5872 Жыл бұрын
Thank you striver bhai. I think your way of teaching and delivering the concept is awesome. For me you are not lesser than GOD. I really don't have words to explain my feelings. @striver
@prabhakaran55424 ай бұрын
Understood ❤
@carefree_ladkaАй бұрын
Hey man , good work . However I wanna point out that you don't need to run your while loop infinitely and break it . We can simplify it as below: function inOrderTraversal(root) { const stack = []; const result = []; while (root || stack.length) { // Go as left as possible and push all left nodes to the stack while (root) { stack.push(root); root = root.left; } // Backtrack by popping from the stack root = stack.pop(); result.push(root.val); // Add the node value to the result // Now, visit the right subtree root = root.right; } return result; }
@sahilmathur73712 жыл бұрын
Hello Striver, You explain code very well. Thankyou for such kind of content.
@samuelfrank1369 Жыл бұрын
UNDERSTOOD. THANKS A LOT.
@bhavkushwaha7 ай бұрын
Thankyou Striver, Understood!
@tps84704 ай бұрын
Easy approach
@fantasyillusion2 жыл бұрын
Those who are looking for python solution # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]: inorder=[] node = root stack = [] while True: if node!=None: stack.append(node) node=node.left else: if len(stack)==0: break node=stack.pop() inorder.append(node.val) node=node.right return inorder
@mannmehta4841Ай бұрын
Without infinite look condition, but O(N) extra space to track we have visited a child node or not - Code: void inordere_traversal_interative(Node* root) { stack st; st.push(root); unordered_map vis; while(!st.empty()) { Node* node = st.top(); if (node->left != NULL and !vis[node->left]) { st.push(node->left); continue; } coutright); continue; } } }
@sanjana82672 жыл бұрын
We love your series! And I can not thank you enough for your efforts!
@abhaytiwari64113 жыл бұрын
thanks, bro for making such a wonderful series
@UECAshutoshKumar Жыл бұрын
Thank you sir
@sonalisingh79322 ай бұрын
understood👍👍
@RahulKumar-rk1tf2 жыл бұрын
Start: 0:43
@coding8000 Жыл бұрын
understooooooooood! Thanks again
@jambajuice07 Жыл бұрын
striver is not a just a emotion . it is a name !
@jasonbrody46183 жыл бұрын
Liked. Cfbr will watch after some time
@nawabkhan49162 жыл бұрын
great work, and have lots of sponsor ad so that you can provide great videos.
@studyaccount7942 жыл бұрын
You're doing god's work here man don't stop.
@1tav02 жыл бұрын
Thank you so much striver i wish i had friends like you in my life
@aayushtheapple6 ай бұрын
Alternative : ```cpp void inorder(Node* root) { if (root == NULL) return; stack st; Node* current = root; while (current != NULL || !st.empty()) { while (current != NULL) { st.push(current); current = current->left; } current = st.top(); st.pop(); cout data right; } } ```
@DeadPoolx1712Ай бұрын
UNDERSTOOD;
@culeforever5408 Жыл бұрын
understood
@armangaming86662 жыл бұрын
really bohot amazing hai ye free ka tree series
@parasgupta13914 ай бұрын
last mei root = node->right hoga naaki node = node->right
@uRamPlus3 жыл бұрын
just discovered your channel! thank you so much for your effort! please dont stop making these tutorials! just subbed
@vedanshsharma1156 Жыл бұрын
bhai phle hi stack empty hojayega 7 k left null par 7 jayega or right null par 1 jayega
@kasyapdharanikota85703 жыл бұрын
thank you very much please continue making such great videos
@mriduljain1981 Жыл бұрын
completed lecture 10 of tree playlist.
@Learnprogramming-q7f8 ай бұрын
Thank you Bhaiya
@ashutoshchaudhary10011 ай бұрын
Wooowwww🎉
@mohammadumaidansari50874 ай бұрын
Understood
@vakhariyajay2224 Жыл бұрын
Thank you very much. You are a genius.
@project_eth4 ай бұрын
*understood*, day2
@cinime2 жыл бұрын
Understood! Super cool explanation as always, thank you very much!!
🚨🙋♂️📢Doubt- What is that while loop doing at line 19, we are not giving any condition, we have just written true? What does it signify?
@KajalKumari-wy6ml2 жыл бұрын
It shows while( !stack.empty() || node != null)
@chakshudeepmeharwal35472 жыл бұрын
Line 26 has it
@curs3m4rk3 жыл бұрын
finally understood this! much thanks to you
@ideepakpandey2 жыл бұрын
thank u so much for this series.....
@codemarshal655 Жыл бұрын
Did you know, you can do iterative in / pre / post order traversals using same code?? Checkout how I did it in just 20 lines, in my new video kzbin.info/www/bejne/bKjbf5ZunKidbqc
@harshitjaiswal94399 ай бұрын
understood.
@rupalikumari88295 ай бұрын
Understood : )
@Mr.Indianwxvhehsy9191hghgx11 ай бұрын
i like it
@pankajsunal98196 ай бұрын
Understood .07/05/2024
@uplsove2 жыл бұрын
This is for people who code in python def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]: stack = [] inorder = [] curr = root while True: if curr!=None: stack.append(curr) curr = curr.left else: if len(stack)==0: break curr = stack.pop() inorder.append(curr.val) curr = curr.right return inorder
@lovetocode92663 жыл бұрын
Is there any optimization while we are using iterative approach. As in iterative approach also we have time complexity of O(n) and aux.space O(n) . Isn't it same if we are using recurrive approach?
@takeUforward3 жыл бұрын
Yeah its just for interviews.
@Cool962673 жыл бұрын
I don't think there can be any more optimization of time, as the name itself says 'traverse' we need to traverse whole of the n nodes.
@bharadwajsaibandaru43232 жыл бұрын
There's actually something called Morris traversal , only for inorder . You can check that out on GFG . It's a bit advanced I guess. It doesn't use recursion and stack even.
@anuraj8979 Жыл бұрын
I understood concept...is any necessary to mugup code?
@jaydalsaniya69863 жыл бұрын
Press L four times at the starting of the video .
@namansharma51283 жыл бұрын
I would have to press it 8 times .......
@_hulk748 Жыл бұрын
Understood sir❤🙏🙇♂
@abhishekjakhmola1434 Жыл бұрын
amazing explaination
@lavanyaprakashjampana9332 жыл бұрын
we love your content and we love you....🖤
@_AkashRuidas2 жыл бұрын
Great Explaination
@jeetpatel78793 жыл бұрын
while(true){ if(node!= NULL){ st.push(node); node = node->left; } else{ if(st.empty()== true) break; node = st.top(); ans.push_back(node->val); st.pop(); node= node->right; } } sir isme ye while(true) konsi condition cheak karta hei?? I mean when its going to be false?
@patrickhudson51683 жыл бұрын
With while(true), the loop will be running infinitely. But here, we have written a condition that when stack becomes empty, the loop will break.
@jeetpatel78793 жыл бұрын
@@patrickhudson5168 then how else condition will run??? You say is st.empty()==true then loop break then in loop how else condition will run??
@shivangisrivastava11583 жыл бұрын
@@jeetpatel7879 Note that break statement is inside an "if" condition, so it runs only when stack is empty, other times else block will get executed.
@jeetpatel78793 жыл бұрын
@@shivangisrivastava1158 when st.empty()==true then loop break then in loop how else condition will run? I checked that and also done dry run of code and the conclusion is when node!=NULL || !st.empty() this both condition is false then and only then loop will terminate
@prabhagaikwad4849 Жыл бұрын
Below code is more cleaner, you may check once, public IList InorderTraversal(TreeNode root) { IList list = new List(); Stack stack = new Stack(); TreeNode node = root; while (node != null || stack.Count > 0) { if (node != null) { stack.Push(node); node = node.left; } else { node = stack.Pop(); list.Add(node.val); node = node.right; } } return list; }
@rahulchandran6482 Жыл бұрын
Very helpful
@sagarchauhan31873 жыл бұрын
Hello Sir, Can you please complete the remaining videos of trees and graph of SDE sheet? please please upload!!🥺🥺
@programmertik20462 жыл бұрын
Here are the iterative traversals with explaination from me //Iterative traversals DFS You need to change only one line recursion simuated !! SC:O(2N) void InOrderIter(TreeNode *root){ unordered_mapstateMap; stacknodes; //push the root first nodes.push(root); while(!nodes.empty()){ TreeNode *currNode=nodes.top(); //if currNode is null simply pop it out if(currNode==NULL) { nodes.pop(); continue; } //if node is not present then initialize it in map //you may or may not do this as the map by default initializes //if key doesnt exist // if(stateMap.find(currNode)==stateMap.end()){ // stateMap[currNode]=0; // } //the nodes left side is not processed yet so process it if state of that node is 0 if(stateMap[currNode]==0){ nodes.push(currNode->leftPtr); } //the nodes left side is processed so process the root now and print its data it if state of that node is 1 else if(stateMap[currNode]==1){ cout
@nagavedareddy58912 жыл бұрын
Huge Respect...❤👏
@sohamdachawar835411 ай бұрын
what si the while condition as in the code it is mentioned only true. but what is that true condition when should the loop stop working...I am unable to frame it in the condition.
@RahulKumar-nd2sp5 ай бұрын
Same doubt
@II-ii2um3 жыл бұрын
What software are you using to draw these explanations man? Really nice colours you have there. Makes it light on the eyes.
@shreyasnagabhushan49182 жыл бұрын
understood sir
@ashitasrivastava681 Жыл бұрын
UNDERSTOOD!
@helloworldkhalid3 жыл бұрын
very nice sir thankyou so much
@chandrachurmukherjeejucse5816 Жыл бұрын
Understood.
@somyasrivastava63152 жыл бұрын
Just Beautiful
@kushagramishra5638 Жыл бұрын
underStood!
@akshatchaube1213 Жыл бұрын
L 10 Done
@madhurgupta91453 жыл бұрын
Keep up the good work
@t-anime5172 жыл бұрын
Understood 😊
@rudranshvyas75393 жыл бұрын
In c++ code what does "TreeNode *node = root;" is actually doing?? at 9:01