Really enjoy your visualizations of algorithms which facilitate learning. Thanks.
@andypaladino37117 жыл бұрын
Thank you so much for making the concepts so easy to grasp!
@TheZwirek6 жыл бұрын
Why most people "explain" the algorithm by going step by step on some example, instead of actually explaining it by explaining the whys and the hows?
@creumakuzola42275 жыл бұрын
I'm making myself the same question. This way we don't understand the algorithm, but the example.
@xenobob27734 жыл бұрын
What whys and hows are there for this code? Its a stack, and its in-order. Its use is printing out a Binary Search Tree in ascending order (as far as I can tell). Thats about it.
@shresthmishra93294 жыл бұрын
Criticising others for self incapability is the first step towards self destruction.
@sohamjoshi95274 жыл бұрын
Spot on... I was wondering the same :) people who need to be given one step after other will learn well from this like @Xeno Bob and @Shresth Mishra...
@FINSuojeluskunta3 жыл бұрын
The only thing you need to understand is how an inorder traversal works. You're just doing it with a stack instead of a call stack and recursion.
@drishyakandpal18504 жыл бұрын
Finally understood the concept! Thank you so much Sir!
@studyaccount7942 жыл бұрын
This channel is gold. The videos are simple yet amazing.
@נדבסלמן-ט2מ8 жыл бұрын
Thank you very much, this algorithm has helped me to solve the problem: " write function that receives a binary search tree and returns a list sorted in ascending order containing all the item int the tree(integer , the list and the tree).thank: public static Node TreeToTHEnode(BinNode t) { Stack s = new Stack(); Node L = new Node(-1); Node lastNode = L; while (true) { if (t != null) { s.Push(t); t = t.GetLeft(); } else { if (s.IsEmpty()) { break; } t = s.Pop(); lastNode.SetNext(new Node(t.GetValue())); lastNode = lastNode.GetNext(); t = t.GetRight(); } } L = L.GetNext(); return L; }
@pruthvigowda79508 жыл бұрын
Yes, that's true. You can do in order traversal for BST (not binary tree) to get the elements in sorted (ascending order). The converse is also true, you can do in-order traversal and check if the elements are sorted (ascending order) in order to determine if the given binary tree is a BST.
@juhabach63713 жыл бұрын
most clear explanation on KZbin.. thanks for such an amazing content
@anujdwivedi52993 жыл бұрын
thanks for the explanation of traversing tree unsing sthack
@kumarc4853 Жыл бұрын
this video doesnt explain the intuition behind the algo but only explains the steps of the algorithm
@lizdenhup4 жыл бұрын
I finally understand thanks to this video!! Thank you!
@kumarakash52193 жыл бұрын
It is wrong code in case of right skewed tree it will not work
@TriforceTech_3855 жыл бұрын
Simple and clear explanation. Thank you
@mukulupadhyay46563 жыл бұрын
very well explained...
@poojask61664 жыл бұрын
Very well explained. Thank you
@HarshaVardhan-jf9sd6 жыл бұрын
Hi tushar...is there no other way to do an inorder traversal iteratively without using a stack and morris algorithm?
@ethanhuang21274 жыл бұрын
how to check one node is visited or not? Using hashset? but that may only work for no duplicates case, right?
@abhigyanshrivastava12554 жыл бұрын
"my name is -char"
@allenllewellynkra4 жыл бұрын
lol u wrong for that
@Laoguang095 жыл бұрын
This is easy to understand, NICE VIDEO!!!
@samisaacvicliph7 жыл бұрын
Excellent explanation. Just a small doubt. Is -1 suppose to be the left child of 2? I'm not sure about 11 as well.
@vinaypatel11067 жыл бұрын
It's for General Binary Tree..not for specific Binary Search Tree..
@starfire_xi6 жыл бұрын
Very very helpful! Thank you so much
@JasmeetSingh-oh8fq3 жыл бұрын
my brain start glitching after seeing this video..
@zineddinelouzani70693 жыл бұрын
this guy is a machine
@josephstrauss96537 жыл бұрын
It's pretty clear! Thanks a lot
@llliuyu7 жыл бұрын
Very clear explanation, thanks!
@rohithbharathi3664 Жыл бұрын
thank you
@thisisthebestid6 жыл бұрын
Can you answer this in interview without knowing the answer beforehand?
@xenobob27734 жыл бұрын
Kinda... its just a stack. And you implicitly use a stack in the recursive version. For 90% of questions though, no.
@vinayak186f34 жыл бұрын
You actually don't need to , just inform them of your approach ,if they feel like you can get to the solution , they'll guide you if you get stuck
@sumeetsood2324 жыл бұрын
What is you tube link to see similar questions? he shared it in end of video but i am not able to understand it
@avisha925 жыл бұрын
Generally speaking, while(true) is a bad practice (in case you accidentally leave no exit routes) and I can imagine the interview calling that out.
@holyshit9225 жыл бұрын
Conversion binary tree to doubly linked list is similar to the traversal (inorder is good when we have binary search tree and want sorted doubly linked list ) but instead of printing key value of nodes we append it into doubly linked list Can we convert binary tree to doubly linked list without recursion and without creating new nodes in time O(n) ?
@ankurshah31122 жыл бұрын
Yes def treeToDoublyList(self, root: 'Optional[Node]') -> 'Optional[Node]': if not root: return None stack = [] temp = root head = Node(0, None, None) last = head final = root while True: if temp: stack.append(temp) temp = temp.left else: if not stack: break temp = stack.pop() final = temp last.right = temp temp.left = last last = temp temp = temp.right first = head.right final.right = first first.left = final return head.right
@kuro72497 жыл бұрын
Thank you so much, this video is really helpful.
@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
@gabriellerosa64534 жыл бұрын
love your videos , im from brazil thx
@deathbombs3 жыл бұрын
recursive so easy and iterative so tough
@yangwang248 жыл бұрын
Thanks a lot.
@CrazySkillz155 жыл бұрын
Thanks. Your video made it so easy to understand. Much Appreciated :) :D
@nocturn20024 жыл бұрын
awesome video
@supremoluminary4 жыл бұрын
How did you figure this out?
@haiphan91815 жыл бұрын
bruh what you smoked send me some
@snlagr4 жыл бұрын
why? i dont get the joke
@anjushajoshi84977 жыл бұрын
I am getting an error when I do this :stacks=new stacksp;
@dhruvyadav11594 жыл бұрын
Always try to avoid dynamic allocation of STL
@rishabhjain24048 жыл бұрын
Thank you!
@junjiezhang45235 жыл бұрын
great!
@cagrsahin41325 жыл бұрын
how is -1 bigger than 11?
@sadhlife3 жыл бұрын
this is not a binary search tree, it's not sorted data, it's just a random binary tree
@arthur68928 жыл бұрын
Thank you so much for sharing this. It's so clear and helps me a lot!
@hemsagarpatel89925 жыл бұрын
nice
@sumodmadhavan5 жыл бұрын
I don't think it is a valid BST because it is not sorted. I hope idea is to only explain Inorder using stack.
@nishantkaushik71614 жыл бұрын
no where it is written that its a "binary search tree".... just a binary tree..
@vishfulthinker5 жыл бұрын
Isn't the time complexity Big O of n and and not 'h'?
@xGXLx3 жыл бұрын
I know this is from two years ago, but h can equal n in it's worst case
@SomnathMukherjee11128 жыл бұрын
please make a video on Inorder Tree Traversal without recursion and without stack! Morris Traversal!
@jbejyz9 жыл бұрын
I think you make some thing wrong in the Binary search tree. The left children of root 10 should less than it and right children should greater than their root
@TheAmonkeys9 жыл бұрын
+Buer Jiang This was a traversal of a binary tree not a BST.
@algorithmimplementer4155 жыл бұрын
Nice explanation :)
@kunalmahajan71427 жыл бұрын
Tushar your videos are lovely. Can you please start making videos on codechef challenges if possible.... It would be really beneficial for us in understanding complex questions. ThankYou! :)
@deathbombs3 жыл бұрын
umm you just jump into algorithm explaining how it works... but no explanation of how to arrive at it?
@kumarakash52193 жыл бұрын
This code will not work in case of right-skewed tree
@kritisingh31943 жыл бұрын
It works fine in case of right-skewed tree. Suppose, root = 15 root->right = 25 root->right->right = 35 root=15 root!=NULL, we will push 15 to stack. root=root->left = NULL So, now as root==NULL, we go to else condition and print 15 Now, root = root->right = 25 And then, you continue following the same process.
@kumarakash52193 жыл бұрын
@@kritisingh3194 yes ty for explanation
@vinayak186f34 жыл бұрын
REVISION NO 3 😶
@shikharjain63575 жыл бұрын
Toosharp!!
@adeled88334 жыл бұрын
i need subtitles
@juanflores22263 жыл бұрын
In python please 🙂
@anoopnayak81067 жыл бұрын
Iterative sika na bp😡
@reviewterrain98356 жыл бұрын
whats "sthack" lol
@konarkverma91025 жыл бұрын
have you smoked weed?
@adityadarekar39637 жыл бұрын
why u r trying an American akcent
@Boarky7 жыл бұрын
Why ask? He's really easy to understand, is he not for you?
@adityadarekar39637 жыл бұрын
Boarky Chup be lvde
@simrandotdev7 жыл бұрын
He has been living in US from last 9 years. So you tend to start speaking certain words how American speaks so they can understand.
@VidyaranyaJayaPrakash6 жыл бұрын
why don't you start off by learning spellings lvde
@mightbeLara5 жыл бұрын
Aditya Darekar Why shouldn’t he ?
@Kushagra_214 жыл бұрын
why do you teach as if we are here to mugg up everything.