Find height of a binary tree

  Рет қаралды 571,315

mycodeschool

mycodeschool

Күн бұрын

Пікірлер: 221
@madhav3444
@madhav3444 4 жыл бұрын
Can't belive these 6years old videos are so much self explanatory and powerful, thanxx mann, you left ds and algo legacy for us
@Kimoskxt
@Kimoskxt 4 жыл бұрын
Factz
@mohdsarim4671
@mohdsarim4671 4 жыл бұрын
yupp thats a very well explanation
@bro......
@bro...... Жыл бұрын
9 years 😅
@xVermyy
@xVermyy 7 жыл бұрын
Your videos helped me understand in 10 minutes what my data structures professor couldn't help me understand in a semester. Thank you :)
@sparshbohra4135
@sparshbohra4135 4 жыл бұрын
source code for people confused: int height (struct bstnode *root) { if (root == NULL) { return -1; } else { int left = height (root->left); int right = height (root->right); int height = (left < right) ? right+1 : left+1; return height; } }
@abuhurrara9171
@abuhurrara9171 3 жыл бұрын
Thanks
@avinashmaurya3625
@avinashmaurya3625 3 жыл бұрын
or you can #include in c++ to make max() function work
@gool7947
@gool7947 3 жыл бұрын
@@bgmishortmoments No it is correct, it should be -1 only because we know height of leaf node is zero but if we take return 0, then it will give height 1 after adding maximum value with 1 (0+1)so it should be -1 only(-1+1) which will ultimately give the height of leaf node zero.
@siddheshchunale1524
@siddheshchunale1524 3 жыл бұрын
aah haa me too used bstnode 🤞
@on_a_grind_rn
@on_a_grind_rn 15 күн бұрын
How are you guys doing man i hope you're doing fine :) . Just curious to know were you guys able to land a job?
@WebgaraCom
@WebgaraCom 9 жыл бұрын
You are here in data structure. You save us in final exam. Please keep going!
@mayank_upadhyay_19
@mayank_upadhyay_19 4 жыл бұрын
Recursion feels like, I am looking in a mirror at myself, who is already looking in his mirror at himself.
@davidlaidbiggestfan212
@davidlaidbiggestfan212 4 жыл бұрын
facts
@pokerfaced8139
@pokerfaced8139 4 жыл бұрын
i am a simple man when i see recursion, i panic
@samkitjain2136
@samkitjain2136 3 жыл бұрын
so true feels like a never ending loop
@usmanGTA
@usmanGTA 3 жыл бұрын
Yeah, but each look at yourself slightly differs... With each look, you lose hair. And right before you get to the break case, you die, your life flashes before your eyes as the recursion begins to reverse and return to all of the stacks above it...
@easynow6599
@easynow6599 2 жыл бұрын
excellent video! especially the fact that for the base case (return -1) you showed how it will work for a leaf node.. here is the Python code: def height(root): if not root: return -1 heightRight = height(root.right) heightLeft = height(root.left) return max(heightRight, heightLeft) + 1
@VarunVishwakarma1
@VarunVishwakarma1 3 жыл бұрын
Why did u stop making videos? Please continue. You are the one who made DS easy for me.
@vikramsapate8703
@vikramsapate8703 3 жыл бұрын
He died in one car accident.
@qR7pK9sJ2t
@qR7pK9sJ2t 5 жыл бұрын
if you know the logic of height and depth.. Directly go to 3:05
@mohammedsadiq1567
@mohammedsadiq1567 4 жыл бұрын
Thank you!
@codysiegmann5637
@codysiegmann5637 5 жыл бұрын
Awesome explanation of the recursive calls as well as the base case (exit condition) and how changing -1 and 0 in the base case will calculate the height of the tree or the number of nodes in the tree, respectively.
@mcirami
@mcirami 10 жыл бұрын
Thank you so much for the videos. I've learned a lot from you. One thing I don't understand about this is how the actual value of the height is found? How is it returning a count of left edges and right to determine which is max?
@mycodeschool
@mycodeschool 10 жыл бұрын
Matteo C You need to watch previous videos in this series to understand how recursion works for trees. Find min and max element in a binary search tree
@11m0
@11m0 8 жыл бұрын
+mycodeschool I watched the video and I still don't get it. How does it count the number of nodes or the number of edges in the left and right subtrees? Is this something that happens in the background?
@cph82612
@cph82612 8 жыл бұрын
+11m0 To calculate the height, you only need to find the path to leaf with maximum number of edges. So you make recursive call to go through the tree, and each time the recursive call returns, the value will be incremented by 1. Say when we're on node 5 in the video, it'll first call FindHeight(root -> left), which goes to node 8. Node 8 will again call FindHeight(root -> left). The left child of node 8 is NULL, so it'll return -1. Node 8 then call FindHeight(root -> right). The right child of node 8 is also NULL, so it'll return -1. Now node 8 will return max(left height, right height) + 1. Since both child nodes of node 8 are NULL and return -1 (max(-1,-1) = -1) , it'll return -1 +1 which is 0. It shows the height of node 8 is 0. Now node 5 calls FindHeight(root -> right), which goes to node 9, and like node 8, it'll return 0 because the height of 9 is 0. And then node 5 returns max(left height, right height) + 1, which will be max(0,0) + 1 = 1. When node 5 return height to node 2 with height of 1, node 2 returns again max(left height, right height) + 1, which will be max(0, 1) + 1 = 1+1 = 2 (left height is height of node 4 which is 0), so height of node 2 will be 2. Because each recursive call returns (something) + 1, and the (something) compares the left and the right height, the maximum height can be determined and incremented in each return.
8 жыл бұрын
+Benjamin Hsu thank you ı really understand.
@lravikiran88
@lravikiran88 8 жыл бұрын
superb sir.... u just made the explanations much more clearer...... and we must all appreciate the way our sir in video used recursion to compute the height ... wow talk about arithmetics on recursion ..
@lravikiran88
@lravikiran88 8 жыл бұрын
sir your logic on how u use recursion for finding the sum is superb.....
@tringuyenucminh167
@tringuyenucminh167 5 жыл бұрын
oh god, you are a good teacher. Easy to understand.
@VISHALBHANDARE
@VISHALBHANDARE 9 жыл бұрын
int maxDepth(struct node* node) { if (node==NULL) return -1; else { /* compute the depth of each subtree */ int lDepth = maxDepth(node->left); int rDepth = maxDepth(node->right); /* use the larger one */ if (lDepth > rDepth) return(lDepth+1); else return(rDepth+1); } } #functionInC
@monicaslv323
@monicaslv323 9 жыл бұрын
+VISHAL BHANDARE Thank you very much. I am so confused about trees. I dont know how i call its recursive functions from main in ADT.
@vijaykari1809
@vijaykari1809 10 жыл бұрын
As we use in general terms, height - measured from bottom to top(i.e.,)from ground level to how much height it went depth - measured from top to bottom (i.e.,) from ground level to how deep it went..
@arnabthakuria2243
@arnabthakuria2243 7 жыл бұрын
You are a great teacher
@krishnasai573
@krishnasai573 8 жыл бұрын
Is it BINARY TREE or BINARY SEARCH TREE..... There is a lot of difference between those two Binary tree :-Tree where each node has up to two leaves 1 / \ 2 3 Binary search tree :-Used for searching. A binary tree where the left child contains only nodes with values less than the parent node, and where the right child only contains nodes with values greater than or equal to the parent. Hope that this is helpful to anybody :)
@lravikiran88
@lravikiran88 8 жыл бұрын
it is bst
@InfamousBlackGuy
@InfamousBlackGuy 8 жыл бұрын
Wouldn't change the process of finding the height of the tree.
@jm.101
@jm.101 4 жыл бұрын
Such a great explanation! Helped me to understand balanced and unbalanced trees!
@gowtham3340
@gowtham3340 6 жыл бұрын
Your voice is perfect. No need subtitles... You just avoid the subtitles , because some of the content not visible
@shivamsaxena5854
@shivamsaxena5854 6 жыл бұрын
you can turn off caption by clicking on the 3 vertical dots showing on the upper right side of your screen
@lynx2244
@lynx2244 4 жыл бұрын
Why don't you turn off the captions then? There might be some students who are deaf or audibly impaired!
@chandramohanrai9314
@chandramohanrai9314 10 жыл бұрын
your videos are amazing..... a student can learn starting from 0 to 90% of data structure in just 3-4 days. can u share link for source code of height of b.s.t.
@khursheedali8286
@khursheedali8286 9 жыл бұрын
we can also do inorder or any traversal and at each node increment count .... now use the formula ceiling( log(n+1) - 1 ) for finding height ... n- nno of nodes
@vasachisenjubean5944
@vasachisenjubean5944 4 жыл бұрын
int height(TreeNode root) { if(root==null) { return -1; } return Math.max(1+height(root.l), 1+height(root.r)); }
@hatsuharu333
@hatsuharu333 8 жыл бұрын
You explain the concepts really well. Thank you!
@navroze92
@navroze92 9 жыл бұрын
Could you please upload videos in dynamic programming it is one of the most powerful and fundamental concepts in computer science if you could do that it would be of great help as there is no one who teaches computer science concepts like you do:)
@jaekim9496
@jaekim9496 9 жыл бұрын
navroze92 Hey! I don't know if you still want to learn about dynamic memory, but he has a series of videos on it if you want to watch it. They are very very very good.
@navroze92
@navroze92 9 жыл бұрын
Jae Kim Could u please put the link for dynamic programming
@yangliu8096
@yangliu8096 9 жыл бұрын
Your video is very enlightening, thank you
@abuzaid4342
@abuzaid4342 3 жыл бұрын
this man was a genius
@roushanraj2155
@roushanraj2155 9 жыл бұрын
Rashmi ,you have to store base condition of each recursion of node
@leontube007
@leontube007 4 жыл бұрын
max is used by #include
@usama57926
@usama57926 6 жыл бұрын
amazing explanation i think u are a tutor
@arbg2566
@arbg2566 3 жыл бұрын
Thanks for this course!
@ashwanivarshney9406
@ashwanivarshney9406 6 жыл бұрын
sir all the videos were very helpful but can you please provide some more videos related to algorithms like red black tree,greedy algorithms graph dfs and bfs and all...
@sarvdeepsangwan1207
@sarvdeepsangwan1207 3 жыл бұрын
one of the partners of mycodeschool died in an accident. so other one decided to not post videos anymore :(
@joyawang5952
@joyawang5952 5 жыл бұрын
Anyone has the same problem with me? The function only returns the result of FindHeight that goes last in the max function parameters. For example, if I put "return max(FindHeight(root->left), FindHeight(root->right)) + 1;" , it returns the height of right, and if I switch left and right like this, "return max(FindHeight(root->right), FindHeight(root->left)) + 1;" , it returns the height of left.
@2222stunner
@2222stunner 6 жыл бұрын
Its worth pointing out that when 'max' is defined as a macro, the tree is traversed in a different order as compared to a function based one. Specifically, in the function based one, a node is visited atmost once. But in macro based one, some nodes are visited many times (verified it by using printf). The results are the same, however. Can someone please explain why it is so?
@hhcdghjjgsdrt235
@hhcdghjjgsdrt235 2 жыл бұрын
int MaxDepth(TreeNode root) { if (root == null) return 0; int HOL = MaxDepth(root.left); int HOR = MaxDepth(root.right); if (HOL >= HOR) { return HOL + 1; } else { return HOR + 1; } }
@nick_kosi
@nick_kosi Жыл бұрын
Thank YOU Very Much for the clarity God bless YOU!!!!!!!!!!!
@kanishknagar2606
@kanishknagar2606 4 жыл бұрын
great work dude
@biochem7092
@biochem7092 7 жыл бұрын
if (root is Null) it should return 0. Because it means, that the upper level node will take it as 0. Code runs line by line, and when it returns, the function is finished, so it won't add +1 to 0. It is fine, that when root is Null, return 0. Please watch other videos and learn from their lectures. I do not agree that you are returning -1 for this function.
@earthwombat
@earthwombat 7 жыл бұрын
i think you were confused by the recursion and which node is which. It will not return at ```if (root == null)``` for node 7 because it is not null, but the leaves are.
@siddharthtrikha2051
@siddharthtrikha2051 9 жыл бұрын
Thanks a lot for all your videos :) Keep up the good work.
@nestorguemez4846
@nestorguemez4846 2 жыл бұрын
excellent video!
@saisanthosh4653
@saisanthosh4653 8 жыл бұрын
Very neatly explained. Thank you
@kevin-kuei
@kevin-kuei 2 жыл бұрын
Brilliant videos!
@CravinMacNCheese
@CravinMacNCheese 9 жыл бұрын
this helped so much. do you have a video on balancing a binary tree?
@santoshr4212
@santoshr4212 Жыл бұрын
this is awesome sir
@arunkumar-ic5rj
@arunkumar-ic5rj 10 жыл бұрын
Very nice explain .Please keep going ....
@rashmih8774
@rashmih8774 9 жыл бұрын
somebody reply please dont we have to make a count here !! like we have to increment the count each time we parse right !
@KrishnaKr
@KrishnaKr 9 жыл бұрын
Rashmi H Thats the beauty of recursion...You need to see previous lectures on binary trees... :)
@VikasYadav-vy4wd
@VikasYadav-vy4wd 7 жыл бұрын
the addition is taking place in this line of code "return max(FindHeight(root->left), FindHeight(root->right)) + 1;" The +1 is always performed after the function is finished being called. We find the lowest depth of the tree and then we break the recursive search for the bottom with (root == null), and we send -1 + 1 = 0 which goes back up and becomes 0+1= 1 which goes back up and becomes 1+1 = 2 which goes up and so on and so on... until we close all the recursive calls.
@GamersCreedTeam
@GamersCreedTeam 6 жыл бұрын
Thanks!
@souravraj9505
@souravraj9505 6 жыл бұрын
@@VikasYadav-vy4wd plz explain the counting more clearly...
@Aman-vd3tr
@Aman-vd3tr 5 жыл бұрын
@@souravraj9505 every time function is used(recursion function) it increments its value by 1
@gmaniket
@gmaniket 10 ай бұрын
Thank you.
@samruddhipatil1812
@samruddhipatil1812 Жыл бұрын
Thanks
@rainaw0924
@rainaw0924 10 жыл бұрын
Thank you for the video and a clear explanation.
@ShivamKendre-fc3su
@ShivamKendre-fc3su 3 жыл бұрын
Great videos
@elijaheinstein160
@elijaheinstein160 7 жыл бұрын
Good one ! Thanks !
@Mr1dent1ty
@Mr1dent1ty 9 жыл бұрын
Really great tutorials!!! Keep it up!!
@T4l0nITA
@T4l0nITA 10 жыл бұрын
really great video, i was wondering, is there a way to implement this function with an iterative algorithm ?
@mycodeschool
@mycodeschool 10 жыл бұрын
T4l0nITA It won't be so intuitive, but yes, any recursion can be implemented using iteration.
@aryanverma7800
@aryanverma7800 3 жыл бұрын
@@mycodeschool Are you in hell or heaven right now??
@ramviswanadhapalli4397
@ramviswanadhapalli4397 Жыл бұрын
​@@aryanverma7800why the fuck would you ask that brooo
@AdarshTrivedi720
@AdarshTrivedi720 9 жыл бұрын
Great explaination.................bang on.....
@deeproy7292
@deeproy7292 6 жыл бұрын
very well explained...thank you
@shohanurrahman9965
@shohanurrahman9965 3 жыл бұрын
///find height of a binary tree int FindHeight(BstNode* node) { if (node == NULL) return 0; else { /* compute the depth of each subtree */ int lheight = FindHeight(node->left); int rheight = FindHeight(node->right); /* use the larger one */ if (lheight > rheight) return(lheight + 1); else return(rheight + 1); } }
@sushantagawane8683
@sushantagawane8683 4 жыл бұрын
Thanks mann !
@sr5726
@sr5726 10 жыл бұрын
Amazing Videos! Could you please tell, what software you are using to capture and make these videos?
@Name-pn5rf
@Name-pn5rf 4 жыл бұрын
can we do the if statement as if(node.left==null && node.right==null){ return 0; } I did it and it gave me errors...why did this happen?
@shivamkumarchauhan9648
@shivamkumarchauhan9648 4 жыл бұрын
when node is null itself then how it will get value of node->left and node->right?
@inclinedscorpio
@inclinedscorpio 5 жыл бұрын
*Return 0 not -1 because the number is returned to parent of leaf node and not the leaf node !!*
@gurramsaikiran9383
@gurramsaikiran9383 8 жыл бұрын
U just nailed it :) :) Thanks
@fsl4faisal
@fsl4faisal 8 жыл бұрын
neat explanation..!! Thank you so much..!
@watchit186
@watchit186 9 жыл бұрын
sir ..nicely done...but one thing i didn't get...nowhere count is incremented.. last leaf node returning -1 to its parent node..but wat its parent node returning to its parent node..its totally confusing..can u explain bit more on this..
@JonWexlerYT
@JonWexlerYT 9 жыл бұрын
ravi kumar In the actual code, he returns Max of two options (left node and right node), and adds 1 to whichever is bigger. That in turn returns to whichever node before that called the recursive function, and that call will also add 1. This continues for each node in the tree until it reaches the root node, which will add 1 to the final result, and return that Integer value to whoever called the function originally. In other words: null leaf returns -1, the node before takes the -1 and adds 1 (=0), the node before that takes the 0 and adds 1 (+1).....(nDepth-1)
@AhmedMahmoud-qu6nq
@AhmedMahmoud-qu6nq 9 жыл бұрын
Jonathan Wexler so please can you explain how the stack works with the line return max (findheight(root->left),findheight(root-.right)); mycodeschool
@elisson357
@elisson357 6 жыл бұрын
Thanks for sharing this.
@ashu3707
@ashu3707 3 жыл бұрын
thanks a lot
@kafychannel
@kafychannel Жыл бұрын
thank you man
@thuanbuibach7284
@thuanbuibach7284 6 жыл бұрын
Thank you so much, you are great teacher ^^
@vangjelgramozi324
@vangjelgramozi324 6 жыл бұрын
And how do you build the max function? Instead of max(a,b) do you write return ( FindHeight(root->left) > (FindHeight(root->right) ? FindHeight(root->left) : FindHeight(root->right) ); Is this correct or no?
@prasanna5836
@prasanna5836 6 жыл бұрын
Here 'FindHeight' function returns an integer,it's like writing return some_int_1 > some_int_2 ? some_int_1 : some_int_2; which is correct.
@mulgamarathikudipunjabi
@mulgamarathikudipunjabi 8 жыл бұрын
Properly Explained !!
@ziddy26
@ziddy26 8 жыл бұрын
how come the height of node 2 is 2?by your definition of height, isn't it is supposed to be 1. If it is 2, then the height of the tree should be 4.
@mehedihasanhridoy1701
@mehedihasanhridoy1701 4 жыл бұрын
yeah i also don't get it
@gabrielpereiramendes3463
@gabrielpereiramendes3463 5 жыл бұрын
Very Good!
@blearchive
@blearchive 10 жыл бұрын
this 's great tutorial
@jinyi0313
@jinyi0313 6 жыл бұрын
how to find possible triangle in binary tree. example if i insert 7 it will return 4 triangle. thank you for answer
@elusk4545
@elusk4545 7 жыл бұрын
At 1:17, you state the height of the tree is 3... Is root not considered part of the tree?
@dustbunnys
@dustbunnys 7 жыл бұрын
Eric Lusk, you can think about it as number of nodes -1 if you want to include the root as part of the tree.
@kayjay1278
@kayjay1278 10 жыл бұрын
can it work for binary search tree also? I mean do we need to make any changes if we want to make this code work for binary search tree instead of binary tree?
@mycodeschool
@mycodeschool 10 жыл бұрын
Binary search tree is only a special kind of binary tree. So, yes , this will work for a binary search tree without any change.
@jr.shivendra4271
@jr.shivendra4271 6 жыл бұрын
it was brilliant...
@sgg2037
@sgg2037 5 жыл бұрын
Hi, do you have a lesson on finding Floor and Ceil from a Binary Search Tree? Thanks.
@shyam5631
@shyam5631 5 жыл бұрын
he is dead.
@SWAPNILMISHRABLC
@SWAPNILMISHRABLC 3 жыл бұрын
@@shyam5631 no he is not. His friend died and not him
@alifdoll6372
@alifdoll6372 Ай бұрын
Awesome
@shailjakantupadhyay5183
@shailjakantupadhyay5183 7 жыл бұрын
+mycodeschool I watched the all your previous videos and understood it but specifically this video i don't get. How does it count the number of nodes or the number of edges in the left and right subtrees? i need more explanation of code with any example.
@alanliang9538
@alanliang9538 5 жыл бұрын
nice vid ma man
@sandeepkumaradvocate4035
@sandeepkumaradvocate4035 7 жыл бұрын
Thanks sir
@siddharthmagadum16
@siddharthmagadum16 4 жыл бұрын
what about the root node being null? the height would be -1? or still 0? . According to the code it is -1 , but I'm doubting on it ...
@siddharthmagadum16
@siddharthmagadum16 3 жыл бұрын
@@bgmishortmoments Hmm, now I would think that just returning -1 is correct as there will be no tree at all if root is null. And Answer would be 0 in case of only 1 node(root).
@bgmishortmoments
@bgmishortmoments 3 жыл бұрын
@@siddharthmagadum16 yah I too realized now
@Fauji_Baba
@Fauji_Baba 8 жыл бұрын
thanx mycodeschool u r like god to me ..
@vu5700
@vu5700 4 жыл бұрын
Whats the output of max function if left is equal to right
@usama57926
@usama57926 6 жыл бұрын
thank u brother
@dustbunnys
@dustbunnys 7 жыл бұрын
Will this technique work for an AVL tree?
@amandeepsaxena9579
@amandeepsaxena9579 7 жыл бұрын
yes exactly same code will work for AVL trees also
@roushanraj2155
@roushanraj2155 9 жыл бұрын
for count
@Luna-fu7ix
@Luna-fu7ix 6 жыл бұрын
thank ya a lot
@divyachowdhary2574
@divyachowdhary2574 8 жыл бұрын
awesome
@prashantgupta808
@prashantgupta808 4 жыл бұрын
how max function is working here without any definition?
@vladyslavmiachkov7431
@vladyslavmiachkov7431 6 жыл бұрын
But if tree wiill be huge that cause stack overflow of recursion doesnt; it?
@obinnaubah9045
@obinnaubah9045 6 жыл бұрын
Yes. That's why there is a more efficient algorithm. www.afternerd.com/blog/python-check-tree-balanced/
@nedadra1
@nedadra1 9 жыл бұрын
really helpfull thank u .
@manishbisht7740
@manishbisht7740 6 жыл бұрын
Can anyone tell me how to find height of a tree represented as adjacency list? BTW great video.
@sensen9235
@sensen9235 3 жыл бұрын
can you use a static variable?
@PauloItaliano
@PauloItaliano 8 жыл бұрын
what is actually a difference between the edge and the leaf???
@memegineer1983
@memegineer1983 8 жыл бұрын
A leaf node will have no left and right children nodes. 4, 8, 9, 6, 7 are leaf nodes in mycodeschool's example because they do not have a left or right child. Unlike 5, which has a left and right child; 8 & 9 and therefore, not a leaf. An edge is the arrow mycodeschool draws between each node. For example, the root node, 1, has two edges that point to the left child, 2, and to the right child, 3.
@mayanksrivastava4452
@mayanksrivastava4452 7 жыл бұрын
edge is the line between any two nodes and leaf is the node which has no children.
@streamcoders3552
@streamcoders3552 3 жыл бұрын
Recursion is like, you are dreaming during sleep and inside dream you are also dreaming, then again inside that dream you are sleeping and dreaming. It's like inception movie :D .
@vijaykari1809
@vijaykari1809 10 жыл бұрын
Hi Sir..Thanks a lot for your videos and in helping me to come out of fear from concept of non-linear DS ..I am not only able to understand these concepts for the first time, but also getting more interest in learning about the concepts. I HAVE A SUGGESTION. Can we logically represent the arrow marks of HEIGHT as edges starting from leaf node to the destination(be it node at any level/root node) & DEPTH with edges(arrow mark) starting from root node to that destination(be it node at any level/leaf node).. This can be a better pictorial representation for clear understanding, to newbies like me. Thanks & correct me if i am wrong.
@monicaslv323
@monicaslv323 9 жыл бұрын
int findheight(struct nodo *root)...how do you call this kind of function from main()??
@11m0
@11m0 8 жыл бұрын
+M. Santos it will look similar to this public static void main(String[] args) { BinaryTree tree = new BinaryTree(); //This is based on the name of your class tree.root = new Node(1); tree.root.left = new Node(2); tree.root.right = new Node(3); tree.root.left.left = new Node(4); tree.root.left.right = new Node(5); System.out.println("Height of tree is : " + tree.maxDepth(root)); }
@yustinayasin5539
@yustinayasin5539 4 жыл бұрын
Hi guys! i've tried this pseudocode in C and the result is "Error: Tree is empty" appear everytime the recursion called. The error shouldn't appear because my tree isn't empty. Can anyone explain my error please? Thank you
@yustinayasin5539
@yustinayasin5539 4 жыл бұрын
@Yash Dave i already resolve the problem. Thank you for intending to help!
@1314520Joanna
@1314520Joanna 7 жыл бұрын
height of a tree and height of node three confuses me, but still nice video
@usama57926
@usama57926 6 жыл бұрын
amazing algorithm
@sergiojimenez3445
@sergiojimenez3445 8 жыл бұрын
anyone could explain me why is O(n) if this is supossed to check all the branches
@miljan9602
@miljan9602 8 жыл бұрын
Dude, you gave yourself a answer. If it needs to check every branch then it is O(n), n is number of branches and it checked every branch once.
Binary tree traversal - breadth-first and depth-first strategies
11:54
Delete a node from Binary Search Tree
18:27
mycodeschool
Рет қаралды 1,1 МЛН
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 60 МЛН
За кого болели?😂
00:18
МЯТНАЯ ФАНТА
Рет қаралды 3,2 МЛН
Молодой боец приземлил легенду!
01:02
МИНУС БАЛЛ
Рет қаралды 2,1 МЛН
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 7 МЛН
Check if a binary tree is binary search tree or not
16:30
mycodeschool
Рет қаралды 380 М.
Height of a Binary Tree / Maximum depth of a binary tree Algorithm [REVISITED]
16:50
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 119 М.
10.1 AVL Tree - Insertion and Rotations
43:08
Abdul Bari
Рет қаралды 1,2 МЛН
Data structures: Binary Tree
16:17
mycodeschool
Рет қаралды 1,4 МЛН
Binary tree traversal: Preorder, Inorder, Postorder
14:29
mycodeschool
Рет қаралды 964 М.
Find Height of a Binary Tree (Algo + Code + Complexity)
10:46
Phyley CS
Рет қаралды 42 М.
L14. Maximum Depth in Binary Tree | Height of Binary Tree | C++ | Java
8:05
Binary search tree - Implementation in C/C++
18:36
mycodeschool
Рет қаралды 1,3 МЛН
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 60 МЛН