Anyone who has no idea about coding,he or she can easily understand what you are teaching. Amazing you are. Bring more and more videos
@freemente47315 жыл бұрын
This will give a stack underflow on the 3rd condition part.... as you pop the last item of the stack and the stack becomes empty.... the loop will check the top of the stack which does not exist causing a stack underflow...... solution to that will be to include a condition after the pop to see if the stack is empty or not.. For example : while(root==stack.top()->right) { root=stack.top(); std::cout
@allan18274 жыл бұрын
yep;)
@anis_coc62276 ай бұрын
Actor 🔥🔥🔥🔥 best teacher ever !!!💪🦾💪💪🔥🦾🔥🦾🔥🔥🦾🔥🦾🔥🦾☠️☠️☠️
@karthikk58956 жыл бұрын
The condition 3 while loop needs a check whether the stack is empty or not.
@bhagvatsinghrajput23133 жыл бұрын
thank you so much sir you helped me a lot for understanding tree traversl
@ramum54245 жыл бұрын
Here, after traversing the children of subtree 'M', if you check for this condition if(p==top.right) { print(top.data); pop(); } At this instance we have only one element 'a'(THE ROOT) in the stack. Now in the 2nd condition, you're again pointing node p to 'A' right child which is 'M', which we've already traversed. Hence causing an infinite loop. So this algorithm works well until traversing the last right subtree of root. We will be able to get the output without the root node in the answer but in an infinite loop. SOLUTION: modify 2nd condition as: (q is a dummy node which points to null) if(!s.empty()) { if(q==stack.top().right) { p=stack.top(); //here p is the root node print(p.data); //prints the root node stack.pop(); //ending infinite loop (now the stack is empty) p=null; } else p=s.peek().right; } else p=null; }
@tridevthakur53974 жыл бұрын
Sir plz continue to make such useful video Thank u sir😊😊
@DhananjayKumar-bd2jg3 жыл бұрын
great explanation!
@batsunet4 жыл бұрын
I love your videos! You've helped me so much in my programming!
@dmputube94 жыл бұрын
p = root; while (true) { if (p) { push(p); p = p->left; continue; } if (isStackEmpty()) break; if (top()->right != null) { p = top()->right; continue; } // process node now currentNode = pop(); process(currentNode); if (! isStackEmpty() && top()->right == currentNode) { // avoid coming back to same node again and loop endlessly, process root of prior currentNode now currentNode = pop(); process(currentNode); } p = null; } believe this looks more clean, overall I trust iterative more than recursive. simply because I can still control size of stack, but not the stack size of recursion.
@surajverma86874 жыл бұрын
Nice explaination sir
@ashishswaraj23514 жыл бұрын
3rd condition if(p=Top().right) is correct this should go to the B element .. so I think it's wrong
@durgashanker64914 жыл бұрын
Hello Sir, can you please post tutorial on Recursion ?
@aabhishek49116 жыл бұрын
One basic doubt , How will you come to the conclusion that 2 nodes are not the same ? if their values or left and right child are not same ? what if 2 nodes having same value and both being the leaf nodes?
@ucleminh16423 жыл бұрын
How to use the Queue to Post-Order traversal binary tree
@vijayhathimare45203 жыл бұрын
if (top().right != null) then ?
@allan18274 жыл бұрын
nice explNATION
@Understanding_the_world_withme4 жыл бұрын
Thank you sir
@rafaelaraujo73514 жыл бұрын
very good
@uditagrawal66035 жыл бұрын
Not working for binary tree : root=1, root.left = 2,root.right = 3, root.left.left = 4, root.left.right = 5,root.right.right = 6,root.left.left.left = 7
Sir please make a video on Morris Traversal please sir
@svdfxd5 жыл бұрын
There is a video posted by Tushar Roy...
@vinaysingh20896 жыл бұрын
sir aap kaise h?? bahut din baad
@vivekanandkhyade6 жыл бұрын
i m good vinay.....soory for the gap...now i can dedicate more time.....keep watching
@an_son_mathew_3 жыл бұрын
💜
@ArpitDhamija4 жыл бұрын
i slept 5 times while listening this
@pruthvirajk60194 жыл бұрын
Did he ask you to watch ! lol ! Dont play jokes.
@samxsharan3 жыл бұрын
@Arpit 😂
@hhcdghjjgsdrt2352 жыл бұрын
I slept 2 times while reading your lengthy informative comment
@lalitkumarmehta60265 жыл бұрын
Please provide code
@Snehal_Javheri4 жыл бұрын
Could you please provide cpp code...Thank You !
@Snehal_Javheri4 жыл бұрын
Sir I have designed code and executed...It is giving me segmentation fault...for STACK.TOP()->Right function....Please help me in this regards....Thank You ! Please send complete code- at s.r.javheri@gmail.com
@hhcdghjjgsdrt2352 жыл бұрын
I m new to coding and it may have some error. here it is C# void postOrDFS(TreeNode root) { Stack stack = new Stack(); stack.Push(root); HashSet prnted = new HashSet(); while (stack.Count!= 0) { TreeNode temp = stack.Peek(); if (temp.left != null && prnted.Contains(temp.left) == false) { stack.Push(temp.left); } else if (temp.right != null && prnted.Contains(temp.right) == false) { stack.Push(temp.right); } else { prnted.Add(stack.Pop()); Console.WriteLine(temp.val); } } }
@srajensingh45326 жыл бұрын
Are sir kaha chale gaye the
@vivekanandkhyade6 жыл бұрын
soory for the gap...now i can dedicate more time.....keep watching
@amanahmed60575 жыл бұрын
Sir hindi me padaa do (*˘︶˘*).。.:*♡
@hhcdghjjgsdrt2352 жыл бұрын
English sikhlo, hindi ka koi value nei hae IT field me