This guy was my junior in Grad School, and here I am learning Data structures from him. Kudos Tushar!
@kartikkankurte7173 жыл бұрын
This is one of the underated channels
@nikhilsharad95538 жыл бұрын
Amazing tutorial and your way of explanation is incredibly easy to follow. Thanks for such wonderful tutorials.
@dominiquesilva47568 жыл бұрын
The method that you used made it very easy for me to understand.
@kevinmeraz81593 жыл бұрын
Amazing. So simple and clear. Huge help. Thanks!
@satang5009 жыл бұрын
Wow I really like the idea of using two stacks. Writing correct code using only one stack without mistakes for a short time was quite challenging for me. As you commented I'll be expecting your video for using one stack too. :)
@vjnvisakh8 жыл бұрын
Thanks a lot ... had this single stack code ... but it was getting a bit confusing ( specially while printing the last node -- root). This code is much better and much more logical.Thank you once again Tushar
@xenobob27734 жыл бұрын
Love how the Indian guys start out with 'Hello Friends'.
@sachinrana3095 жыл бұрын
These videos got me job!!!Thanks a lot
@punitoza847 жыл бұрын
Thanks Tushar, your videos are helping a lot and making the data structures revision far less daunting.
@aakashbhatia2 жыл бұрын
easy to understand explanation
@sudipsaha96777 жыл бұрын
thanks ..u made my coding journey easy
@karthikr6447 жыл бұрын
Very useful, I was struggling to find an approach. This is a neat solution.
@AmoghNatu6 жыл бұрын
Thanks Tushar. This is a great solution. However, can you also explain the thought process of actually "arriving at the idea of using 2 stacks"? I'm struggling with that? Meaning, how did you get the idea in the first place that we can use 2 stacks to solve this? Can you also put here the thought process of arriving at this solution approach? Many thanks!
@albertt90975 жыл бұрын
you can think of the 2nd stack as a visited tag (another approach to solving this). Or you can think of it as a 2nd push to the stack (a 3rd approach similiar to his other postorder vid)) Lastly you can see it as a reverse preorder visualized here.
@rituagrawal22188 жыл бұрын
Very nice video. Waiting for 1 stack postorder iterative traversal video . :-)
@koustavchatterjee29078 жыл бұрын
Java Single Stack Solution code.geeksforgeeks.org/n1XgVe
@rituagrawal22188 жыл бұрын
Thanks Koustav
@cantwaittowatch8 жыл бұрын
Very nice tutorial Tushar. I tried using one single stack which needed a counter to keep track of how many times elements have been popped or visited so not to process them again. Gets bit tricky!!!
@fxjing6 жыл бұрын
very good approach and explanation. thanks.
@muskanroxx223 жыл бұрын
The method for using two stacks doesn't seem very intuitive, to me all the iterative codes for Preorder, Inorder, and Postorder don't seem intuitive enough. I am able to understand this but if someone would have asked me to directly come up with an iterative algorithm for traversals it wouldn't strike me. So, do we just learn this as an algorithm- it is what it is? I understand why it works looking at it's implementation, are we supposed to cram some of these things in order to prepare for our interviews?
@savantdude3 жыл бұрын
let me guess.. you have trouble understanding the fundamentals of CS too?
@jeffereycountryman67713 жыл бұрын
very clear. Thank you very much.
@sidk59197 жыл бұрын
thanks gautam gambhir
@tusharroy25257 жыл бұрын
lol
@OverLordOfDa3rdWorld4 жыл бұрын
Wow, amazing. Thank you so much!
@Null_pointer_exceptn9 жыл бұрын
Thanks. we can also use just 1 stack .
@kshawal8 жыл бұрын
Thanks.. very easy to understand
@rishabh70114 жыл бұрын
Thank you sir ji
@FamousEgyptboy6 жыл бұрын
very well explained Thank you !
@shwetashukla72915 жыл бұрын
Thanks this was very helpful
@talaviss1236 жыл бұрын
very well explained
@engel154966 жыл бұрын
Nice video!
@naveennagar097 жыл бұрын
thank you sir..very well explained :)
@someshsharma10948 жыл бұрын
Nice video... Please upload the Postorder Traversal with Single Stack... :)
@urrahman1963 жыл бұрын
Great video, please rename it using two stack
@ninadpradhan65669 жыл бұрын
nice one bud!
@adhishmalviya24084 жыл бұрын
Nice
@trangbui19105 жыл бұрын
thank you
@lohittalasila8 жыл бұрын
Thank you :)
@yunus.yildirim7 жыл бұрын
Can u add a new lesson for Internal Path Reduction trees?
@raghuram4635 жыл бұрын
Does Non-recursive algorithm and Iterative algorithm mean the same for Post order traversal of Binary tree?
@sumeetsood2324 жыл бұрын
can you please share link where this is done by reccursion, i cannot find it on your channel
@anuragdani97398 жыл бұрын
I have a question, why have you implemented with Deque instead of Stack in the implementation?
@Kavishkhullar4 жыл бұрын
this particular solution works but why is that? am i just suppose to memorize this logic/algorithm?
@apple20927 жыл бұрын
Thanks for sharing and it's a good solution. But I'd more like to know how to figure out such a solution?
@raghavchadha91338 жыл бұрын
data structures book Seymour lipschutz ....traversing binary tree using postorder ..
@bighneshsabat53748 жыл бұрын
nice explanation,but i need one stack implementation.
@GaganGrewalf0958 жыл бұрын
It will basically be a Depth-First traversal ? We still need some kind of tracking collection to record visited nodes... is that correct ?
@wentaohu17066 жыл бұрын
hi Gagan, I can answer your question, based on your assumption: "We still need some kind of tracking collection to record visited nodes", I wrote 2 algorithms to compare , a wrong one and a correct one, and each has detailed explanation, pls check my github repo: github.com/adalucky1234/Tree-Implementation-Java , go to master branch, then you easily find it. Thanks!
@shivajunna5 жыл бұрын
How did you come up with two stacks idea?
@creativity44168 жыл бұрын
GOOD ONE (Y)
@raghavchadha91338 жыл бұрын
there is some method ..right child is negative ...what abt that ..it is not considered here
@raghavchadha91338 жыл бұрын
+Tushar Roy we are pushing right child as negative ..nd left child positive ...then. backtrack if no left child .. then process positive ...if there is negative right child ..then we make it positive nd again process it . .its done In my book ..bt my basic question is why we take right child as negative
@raghavchadha91338 жыл бұрын
+Tushar Roy its done using one stack ...bt I watched ur one stack ..bt there also ..there was no negative right child
@prabhakarpalanivel64726 жыл бұрын
This is more of a "reversed" preorder search followed by reversing the list using another stack
@SangharshSeth4 жыл бұрын
can you link to a true iterative implementation
@manvityagi65294 жыл бұрын
The only bad thing is : He rarely shares the thought process and jumps directly into the solution.
@akshatjain68544 жыл бұрын
rightly said
@savantdude4 жыл бұрын
ahh right, everything has to be fed to you so you can regurgitate it in interviews!
@twndomn4 жыл бұрын
Assuming this is Java, it's Not recommended to use Stack data structure, use Deque instead. Stack was implemented using vector in the early Java days, outdated and inefficient, also bad for job interview.
@swagatpatra21394 жыл бұрын
public List postorderTraversal(TreeNode root) { Deque q = new LinkedList(); List res = new ArrayList(); if(root == null) return res; q.addLast(root); while(!q.isEmpty()){ TreeNode curr = q.removeLast(); res.add(curr.val); if(curr.left!=null) q.addLast(curr.left); if(curr.right!=null) q.addLast(curr.right); } Collections.reverse(res); return res; }