Please likeeee, shareeee and subscribeeeeeeee :) Also follow me at Insta: Striver_79
@democratcobra3 жыл бұрын
Understood
@sarthakbhatia78883 жыл бұрын
done
@AbhishekKumar-vr7sh3 жыл бұрын
Yesterday I gave my paytm interview and all the dsa questions asked were from the sde sheet. Moreover, the questions asked from the core subjects were from the core sheet. I was able to crack the interview with great ease all thanks to striver bhaiya OP. You are the best mentor in this world 🔥
@AbhishekKumar-vr7sh3 жыл бұрын
@Himanshu Kataria 😂😂😂
@debanjan_poddar3 жыл бұрын
You gave the interview yesterday.. How are you already sure that you will be selected?
@AbhishekKumar-vr7sh3 жыл бұрын
@@debanjan_poddar It was an on campus interview. Results came out that night itself. Processing is faster in case of on campus placement.
@AbhishekKumar-vr7sh3 жыл бұрын
@@aadeshsharma0001 thanks bro
@singhsahab94783 жыл бұрын
@Himanshu Kataria lol
@111rhishishranjan2 Жыл бұрын
vector Solution::preorderTraversal(TreeNode* A) { stackst; TreeNode*node =A; vectorv; while(!st.empty() || node != NULL){ if(node != NULL){ v.push_back(node->val); st.push(node); node = node->left; } else{ node = st.top(); st.pop(); node = node->right; } } return v; } //this is a nice stack approach . with more clean code.
@curs3m4rk3 жыл бұрын
watched a lot of videos for iterative traversal, but this one hit my brain in first attempt. Your explanation is great man
@aryanpinto5105 Жыл бұрын
Was just able to code on my own. The way you give the intuition is just next level. Tysm Striver. Grateful to have a teacher like you.❤💯
@piyushsaxena62432 жыл бұрын
this is the best tree series till date , thanks a lot striver, would be really helpful if you could bring a playlist on dp on trees as well for both cp and interviews.
@shivangisrivastava11583 жыл бұрын
i am thrilled at my transformation, i was able to write correct code before looking at your code! Tysm bhaiya😵♥️
@harshvardhanmishra10722 жыл бұрын
Started this tree series today and I don't know when I come up to the Lecture number 9. Such a wonderful explanation. Thanks you so much Sir for doing so much effort for us.😊
@Ishan3013 жыл бұрын
Striver is life saviour for tier-3 college guys like me. Thank you.
@Codeology7083 жыл бұрын
This Man Is a great example for those who say you can get a placement in Giant MNC's . Thanks Bhaiya You inspired me a lot
@abhishekanand68472 жыл бұрын
What ,it means --- Vectorpreorder Traversal(Treenode* root )
@user-vaidesh10 ай бұрын
It means the function is returning a vector that contains data in the form of integers and the function takes a struct or class of node to represent a treee
@thegreekgoat983 жыл бұрын
What an explanation!!!!! I wrote the C++ code by myself after watching the explanation part...
@vishalwaghmare31302 жыл бұрын
This is the best channel I have come across on Data Structures/Coding. Thanks a lot!
@vasudhajha91152 жыл бұрын
Hello Striver! I hope you're doing well :) Thank you so much for making these series that newbies like me can come back to again and again. The passion that you bring to teaching is infectious and in a sea of tutorial hell, your tutorials are a guiding light and the best path to follow! Really appreciate the effort that you put to help countless people. Your work is inspiring.
@tech_PersonalityАй бұрын
00:35 Iterative preorder traversal in binary tree 01:22 Iterative Preorder Traversal in Binary Tree is done using Stack 02:12 Iterative Preorder Traversal in Binary Tree using Stack 03:11 Iterative Preorder Traversal in Binary Tree using Stack 04:32 Importance of right side effects on mental strength 05:27 Iterative preorder traversal in binary tree is efficient and useful
@Manasidas99 Жыл бұрын
Sir your teaching style is really unique.
@manasgupta6647 Жыл бұрын
yep
@shashibhushanrajput24613 жыл бұрын
Nice simple explanation bhaiya.. please make a serious on medium and hard DP problems. Because right now DP is really in demand at Interviews.
@lifehustlers164 Жыл бұрын
Completed 10/54(18% done)!!!
@stith_pragya Жыл бұрын
Thank You So Much for this wonderful video.....🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@AdityaKumar-be7hx Жыл бұрын
We can avoid a few extra checks to write a smaller code: class Solution { public: vector preorderTraversal(TreeNode* root) { vector preorder; stack st; st.push(root); while(!st.empty()){ auto curr=st.top(); st.pop(); if(curr!=nullptr){ preorder.push_back(curr->val); st.push(curr->right); st.push(curr->left); } } return preorder; } };
Very Nice way. I used to write the preorder code using the inorder traversal with slight updation.
@tanishq2766 Жыл бұрын
I did the same, but I found this approach more intuitive !
@sharmanihal996 ай бұрын
Just in case someone is looking for the python code for the above: class Solution: def preorderTraversal(self, root: Optional[TreeNode]) -> List[int]: #Iterative Solution if not root:return stack=[root] ans=[] while stack: top=stack.pop() ans.append(top.val) if top.right: stack.append(top.right) if top.left: stack.append(top.left) return ans
@cinime2 жыл бұрын
Understood! So amazing explanation as always, thank you very much!!
@apmotivationakashparmar722Ай бұрын
Thank you So much Striver . Please upload Complete String in A-Z Dsa Sheet.
@somyapratapsingh98492 жыл бұрын
Looks like watch whole series in one go :))
@per.seus._ Жыл бұрын
understood🌏
@chiragbansal33643 жыл бұрын
Awesome explanation in just 6 mins
@nawabkhan49163 жыл бұрын
great work, and have lots of sponsor ad so that you can provide great videos.
@rahatsshowcase86142 жыл бұрын
Recursion uses already stackspace But we are again usig that stack separately!Something new i likeit
@prathameshjadhav294210 ай бұрын
Nice teaching bro.....
@lavanyaprakashjampana9332 жыл бұрын
we love your content and we love you....
@samuelfrank1369 Жыл бұрын
UNDERSTOOD. THANKS A LOT.
@bhavkushwaha7 ай бұрын
Thankyou Striver, Understood!
@PranjalGunjanDiaries Жыл бұрын
YOU ARE THE BEST..
@vakhariyajay2224 Жыл бұрын
Thank you very much. You are a genius.
@Learnprogramming-q7f8 ай бұрын
Thank you Bhaiya
@sonakshibajpai64455 ай бұрын
understood!! thanks striver
@sonalisingh79322 ай бұрын
understood👍👍
@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
@BharatKumar-rc8vn4 ай бұрын
cool stuff
@coolgaurav51634 ай бұрын
Understoood
@bhaveshkumar68422 жыл бұрын
Immensely grateful for your content
@SambhavJaincs23m0602 ай бұрын
0:48 START
@ErgoswamiАй бұрын
Completed!
@sagarchauhan31873 жыл бұрын
Hello Sir, Can you please complete the remaining videos of trees and graph of SDE sheet? please please upload!!🥺🥺
@1tav02 жыл бұрын
thank you so much for these series
@sidvyas2 жыл бұрын
Bro once you explain most of the time I am able to code the logic by myself. Thanks so much man!!
@DeadPoolx1712Ай бұрын
UNDERSTOOD;
@nagavedareddy58912 жыл бұрын
Huge respect..❤👏
@anshikagupta585811 ай бұрын
Thankyou Striver:)
@theSeniorSDE3 жыл бұрын
Striver, Completed this Question
@mahaveerbana20312 жыл бұрын
dil se thank you striver
@PrashantSingh-jy6zp3 жыл бұрын
for best experience go to 0:48
@pradipkumarmukhi15 күн бұрын
Understood!!!
@codeman38288 ай бұрын
Understood
@culeforever5408 Жыл бұрын
understood
@UECAshutoshKumar Жыл бұрын
Thank you sir
@bhushankorg56062 жыл бұрын
Nice explaination!
@jankeshchakravarthy9389 Жыл бұрын
Great video, I did not understand where are you printing?
@_AkashRuidas2 жыл бұрын
great explaination
@vakhariyajay315 Жыл бұрын
Thank you very much.
@mriit30258 ай бұрын
I just realized how much I lost the time which should be used to understand the deep logic and the code will be automatic... In my second year of Btech, I had a DS (Data Structure) course, but I just understood the surface logicrememberedember the code mostly which was enough for getting 9/10. as iterative code was not important I was too lazy to understand it. so, my advice to myself is : Did you really understand? really? check? like. I completed a module in DS and just remembered the code, am I able to do a dry run of the code and understand the working! remember don't procastinate!
@aditisharma57452 жыл бұрын
You are the best!!
@itsmepiyushsaha3 жыл бұрын
Superb explanation!
@rohankrishnani2 жыл бұрын
Please make video on circular queue implementation as well
@gangsta_coder_123 жыл бұрын
Excellent explanation as always 🔥🔥🔥🔥🔥
@codenchill7323 жыл бұрын
You made it so simple !! thanks alot
@Mr.Indianwxvhehsy9191hghgx11 ай бұрын
nice
@kasyapdharanikota85703 жыл бұрын
best explanation
@sofikulmallick37663 жыл бұрын
amazing explanation!
@ramulala93653 жыл бұрын
Great Explanation!
@rexitspersonal83532 жыл бұрын
converting recursive preorder to iterative public static List preorderTraversalSecond(Node root) { List ans = new ArrayList(); Stack ds = new Stack(); if (root == null) return ans; Node node = root; while (true) { if (node != null) { ans.add(node.val); ds.push(node); node = node.left; } else { if (ds.isEmpty()) break; node = ds.pop(); node = node.right; } } return ans; }
@D44Aishwarya Жыл бұрын
thanks a lot sir!
@letmeinthefiend85222 жыл бұрын
instead of taking right - left in stack.. can we use queue so that we can use left-right approch .. i learn preoder by rootleftright.. stack approach making confusion right before left
@tejas73792 жыл бұрын
No, it's not possible using queue. Regarding stack approach, think how stack works. Since right goes before left, left node will be popped and explored first, then the right node.
@psibarpsi2 жыл бұрын
@@tejas7379 Why is it not possible to use queue here? Can you please elaborate?
@tejas73792 жыл бұрын
@@psibarpsi In stack we push right and left. Then when we pop we get left first and add its children to stack. So when we pop again we will be traversing all left children. So before we reach right part, we would have completely traversed left sub tree. Now lets say we use queue, we push left first and then right. [left, right]. So when we pop we get left first and then we push left's children to queue, like [right, (lefts children)]. When we pop again we will be exploring right subtree then again left sub tree's children. Which is wrong.
@aakriti12 жыл бұрын
@@tejas7379 Thanks for the nice explanation of why we're using a stack here and why we can't make use of a queue for this question.
@tejas73792 жыл бұрын
@@aakriti1 Glad it helped.
@priyanshupandeypandey79942 жыл бұрын
jiiiiiiiooooooo guru jiiiiiiii
@akshaibaruah17202 жыл бұрын
Beego of N (hehe love ur videos)
@mriduljain1981 Жыл бұрын
completed lecture 9 of tree playlist
@abhijeetbasfore68162 жыл бұрын
Thank you
@ganavin34232 жыл бұрын
understood
@yashmandaviya13562 жыл бұрын
What is the purpose behind using extra space of the stack , its not improving the time complexity of the preorder traversal?
@as_a_tester2 жыл бұрын
tysm striver bhai
@Ankit.yt_8852 жыл бұрын
Great Work as always! :)
@prateekverma91663 жыл бұрын
THANKS STRIVER
@utkarshsharma66502 жыл бұрын
understoooood. thanks :)
@harshitjaiswal9439 Жыл бұрын
Understoooooooood!!!
@artitech66682 жыл бұрын
Amazing
@singhs_aniket3 жыл бұрын
Understood 👌👌
@bhavya8608 Жыл бұрын
wonderfull!!
@t-anime5172 жыл бұрын
Understood😊
@senseiKakashi072 жыл бұрын
this is somewhat like recursion, as recursion uses stack behind the scenes, right call tu wait kar mein pehle left hoke aata hu😂
@kirtikhohal33132 жыл бұрын
loll
@mahaksharma782710 ай бұрын
👏👏👏👏
@guruprasadkancharla55552 жыл бұрын
why are we using stack? Is there any specific reason? We can do this using Queue also ?
@harshsinha32212 жыл бұрын
Queue should be used for Level order traversal, preorder traversal uses recursive call, so you can figure out that recursion itself uses stack DS
@DevanshuAugusty Жыл бұрын
shouldn't we take a temp node for root cause we dont want to modifie the data