I thought you counted edges for depth and height, not the nodes?
@tumptytumtoesАй бұрын
absolutely beautiful. No other video actually spends time on the call stack!
@iFrostGraal11 ай бұрын
Hi Stephen, loved the video! I would be very interested to learn how to implement memory into the chatbot if you'd be able to break this down :)
@Richard-yz2gy Жыл бұрын
Hi Stephen, if "3.left" is None=0 from the right side of the tree then how can you put left= 3 in the final return statement surely it should be 0 because the last value for the varaible for "left" is 0 not 3 surely?
@frazebean5117 Жыл бұрын
Thank you mate I love your video.
@xyzoooo401 Жыл бұрын
Hi how is this linked to a stack ? Is stack only used for visualisation ? TIA The pseudo code seems much more straightforward. dfs(n, visited): print(n.value) for a in n.adjNodes { if !visited.contains(a) { dfs(n, visited) } }
@rathan235 Жыл бұрын
Great job
@pettymanny6487 Жыл бұрын
To be true Only because of this video I understood how to solve this problem!
@ejsafara456 Жыл бұрын
god bless ya!
@sononsoft5253 Жыл бұрын
One of the best explanation out there!
@BagsyBag Жыл бұрын
I was confused about why the second while-loop only dealt with the elements in the left sub-array and not the elements in the right sub-array. The way I understand it is: - The second while-loop is needed in case "helper position-j" reached the end of the right sub-array in the first while-loop. - Another while-loop is not needed if "helper position-i" reached the end of the left sub-array in the first while-loop because: 1. The right sub-array's remaining elements are guaranteed to be of higher value than the elements in the sorted portion of "numbers-array". 2. Each of the two sub-arrays is by itself already sorted. - This means that the right sub-array's remaining elements are all of higher value AND already sorted. - The remaining elements in "numbers-array" are the same as in "helper-array" since that is just a copy, so we are done. Maybe it's just me that got confused about that but there you go. I think that's how it works...
@siriuz9279 Жыл бұрын
well explained
@tahakhan3963 Жыл бұрын
thanks a lot for the explanation
@lappham69152 жыл бұрын
Clear!!
@jacob.lee3802 жыл бұрын
I've been watching more than 10 videos to understand how binary tree traversal and recursion work. This is the first video I truly understand both concepts! Thanks!
@rocknikhil59052 жыл бұрын
Recursion part in merge sort always confused me and no other video explained the flow. Thanks to you now I finally understand it.
@echoness_2 жыл бұрын
I just a bit confused how you discovered the combination formula. I guess this is the hardest part for solving the problem.
@spiritualgyanhindi26812 жыл бұрын
Really i got it this time! Finally at here...
@menoima95012 жыл бұрын
omg bless you lad
@bennet54672 жыл бұрын
Excellent explanation. Thanks sir!
@mikkoylimannila81042 жыл бұрын
Thanks, this helped me in my computer science class!
@DeepakYadav-jc8mo2 жыл бұрын
intuitive explanation!
@Mobilizes2 жыл бұрын
this video helped me immensely, i was getting incredibly frustrated on learning dynamic programming because it looked really complicated. this video is simple and thats just what i need to understand! thank you
@MrZH62 жыл бұрын
Awesome! Thanks, really helpful.
@moamenzakaria47712 жыл бұрын
Sounds like it can't be simplified more, but I still feel too stupid to get it :\
@tinyu18042 жыл бұрын
nice explanation ! thx you soooo much for my mid exam
@siomarapantarotto2 жыл бұрын
What a great explanation! Congrats and thanks for sharing this content.
@vishwanathchintala20002 жыл бұрын
man you arraymazing
@salmonmonkey242 жыл бұрын
Excellent explanation of the inner workings of merge sort! Just what I was looking for. Thank you!
@TonyDiCroce2 жыл бұрын
Ok so instead of the recursive state of a stack frame representing a sub problem we use an array. This is clearly more flexible than recursion because it's trivial for the computation of a sate to reference arbitrary other states without those values having to be threaded through function arguments and returns.
@shirishherwade66802 жыл бұрын
If you are searching/liking this video means you came here for recursion and not for merge sort. As you already understood the algorithm but bit confused about how recursion calling happening.
@rishabhchauhan60162 жыл бұрын
helped a fuck out of me !!
@Gman-kx9dr2 жыл бұрын
the cleanest explanation I can find on youtube...especially about the recursion which trips me up all the time... a bunch thanks man ...
@user-sw1wq8lh2w2 жыл бұрын
wow, so good.
@ratmouse0882 жыл бұрын
great video
@gergerger532 жыл бұрын
3:40 - "The amount 2 is greater than 1, so we move on" - this sounds like you're saying it should be skipped, but you go on to use it. I don't think "move on" is the right phrasing for this part of the video (if the goal is to provide a clear and easy / unambiguous explanation of the problem).
@corymaklin78642 жыл бұрын
You're amazing
@simiyutube2 жыл бұрын
i know this is rather old video but was most helpful after digging around for ages to find a straight forward explanation of the dynamic programming solution to this problem. Thanks Steve
@ne4rys2 жыл бұрын
clear, simple and short explanation. best tutorial
@rezwanislam13322 жыл бұрын
thank you so much for doing this in such a concise manner. I learned more from this short video than I did in a whole semester.
@bhaskargoud8933 жыл бұрын
excellent explanation
@mohammedalkhateem3 жыл бұрын
This is a useless video, like I understood everything and you explained it clearly, but the video is basically saying here's a solution and this is why it works. How did we come up with that solution and what was the thought process? you're on your own. This is basically a video for someone who's trying to memorize as much leetcode problems as they can to prepare for an interview or whatever, not for someone trying to learn
@sanchitbhatnagar72833 жыл бұрын
Hey, can someone help me at 5:30, i wondering if the recursive mergesort divides until low<high, then how is it that have merging the first two individual elements, it will mergesort and then merge. ?
@udayptp3 жыл бұрын
Which software you used to make this video, specially i liked your animation work
@lover13013 жыл бұрын
I got stuck with merge sort fews day and you helped me
@lellajagadeeswar5963 жыл бұрын
thank u very much
@wadigzonDiazwong3 жыл бұрын
Memorization is not the same as understanding, I came here to understand the problem, and this explanation falls short from that, I was not looking for a formula but for an approach that will work with other similar problems, though the video gives you the generic formula it doesn't explain its origin. one intuitive way to go about the formula is as follows: for our base case where amount = 0 and any number of coins, we only have one combination: no coins also, for any amount>0 and no coin, there are zero combinations say we have one coin [2], and one amount = 10 we can see that before we reach 10, we will reach 8 (10-2) and then 6 (8-2), and so on until we reach 0 (2-2) our table would look like this for amount 10 and coin [2] amount| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ------------------------------------------------------------------ coin=0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ------------------------------------------------------------------ coin=2 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | ------------------------------------------------------------------ which makes sense, there's one way to do 10 with type 2 coins: 2+2+2+2+2 now say we add one more coin type (3) and our coin array becomes [2,3] we can reuse the existing table to compute the new number of combinations, we just add whatever was in that slot in the previous table so table[amount] = table[amout] + table[amount - coin] and we only care for when amount - coin >= 0 amount| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ------------------------------------------------------------------ coin=0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ------------------------------------------------------------------ coin=2 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | ------------------------------------------------------------------ coin=3 | 1 | 0 | 1 | 1 | 1 | 1 | 2 | 1 | 2 | 2 | 2 | ------------------------------------------------------------------ we can add another coin (4), our new coin array becomes [2,3,4] amount| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ------------------------------------------------------------------ coin=0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ------------------------------------------------------------------ coin=2 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | ------------------------------------------------------------------ coin=3 | 1 | 0 | 1 | 1 | 1 | 1 | 2 | 1 | 2 | 2 | 2 | ------------------------------------------------------------------ coin=4 | 1 | 0 | 1 | 1 | 2 | 1 | 3 | 2 | 4 | 3 | 5 | ------------------------------------------------------------------ So the total number of combinations to get 10 from coin [2,3,4] is 5 they are, 2+2+2+2+2, 2+3+2+3, 2+4+2+2, 2+4+4, 3+4+3, Here is the JavaScript solution: var change = function(amount, coins) { const table = new Array(amount+1).fill(0); // no coin is a combination // to get amount = 0 table[0] = 1; for (let coin of coins) { for (let i=0; i< table.length; i++) { if (i >= coin) { table[i] += table[i - coin]; } } } return table[amount]; };
@ellisarmeanca22233 жыл бұрын
thank you so much
@swayamprajapat61543 жыл бұрын
totally stupid explanation , why TF would you make a video to dictate the CODE???