Table of Contents: (This was one of the first videos I made. Audio sucks. Lighting sucks. It is pretty bad. I'm sorry.) Intro & Video Setup 0:00 - 0:33 Problem Introduction 0:33 - 2:00 Iterative 2:00 - 6:08 Recursive 6:08 - 9:42 Recursive (Detailed Walkthrough) 9:42 - 13:26 Conclusion 13:26 - 13:49 For the recursive way forgot to stress the line saying "head.next = null", this ensures that you point the last node in the reversed portion (built slowly as we go upwards in the recursion) to null. This is important.
@mrknight4115 жыл бұрын
As for the recursive solution, I believe people are confused about head.next.next=head and head.next=null operations because they're not seeing that both rlh and head are referencing the same mutable node objects in heap. In stack where head.data is 3: rlh is 4 head is 3->4 head.next.next=head is 3->4->3->4... head.next=null is 4->3, since it removes all "next" obj ref in 3 to 4, leaving intact 4->3 Since 4 now points to 3 in memory, rlh becomes 4->3 ** debug the recursive solution in your IDE and place a breakpoint on line head.next=null. You will see that rlh.next is now node 3. In stack where head.data is 2: rlh is 4->3 head is 2->3 head.next.next=head, which is 2->3->2->3... head.next=null is 3->2 2 Now rlh is 4->3->2 2 And now the main stack: rlh is 4->3->2 head is 1->2 head.next.next=head is 1->2->1->2... head.next=null is 2->1 , since the obj ref from 1 to 2 is removed Now rlh is 4->3->2->1 , since 2 now points to 1. Recursion is not easy to wrap your head around, especially when dealing with references (or pointers). You did a good job explaining the stack, but you missed the heap :)
@sarfarazalam60775 жыл бұрын
Yeah, I was also wondering why use "head.next = null". Thank you, for clarifying this! Thanks for the video!
@BackToBackSWE5 жыл бұрын
yo
@irfaanjamarussadiq55005 жыл бұрын
Honestly I didn't really mind audio/lighting quality. But I think you could speak a little slower, because it kind of stresses me out when you speak so fast and it's also harder to understand that way. Beyond that, this was a really nice explanation!
@BackToBackSWE5 жыл бұрын
@@irfaanjamarussadiq5500 old video
@5astelija753 жыл бұрын
I never imagined learning code would be this intense
@WildThoughtsAI2 жыл бұрын
lmao
@joshuamarcano3502 жыл бұрын
🤣
@Working8002 жыл бұрын
I like your comment, it is a bitter true a few people discuss lol
@anitasingh-jf1ql5 жыл бұрын
This is literally the best explanation of reversing a linked list on youtube!!!
@BackToBackSWE5 жыл бұрын
thx
@stinkykyle965 жыл бұрын
You seem so excited to explain the problems, it makes your videos engaging 😁 But honestly this is some of the best interview prep that I've gotten, especially since I'm a visual learner.
@BackToBackSWE5 жыл бұрын
Great! :) -Ben
@fardin_shaik5 жыл бұрын
No one can explain recursive thinking better than you, man. Respect
@BackToBackSWE5 жыл бұрын
hahaha thanks
@didi_102422 жыл бұрын
I have been preparing interviews for data scientist positions, and the coding part of the job is not too easy for a person without a computer science background. I was struggling in understanding the recursion function for a really long time, and this is the first time I finally understand it intuitively after watching your video. Thank you so much! Your call stack illustration helps a ton!
@BackToBackSWE2 жыл бұрын
Thank you, glad you liked it 😀 Do check out backtobackswe.com/platform/content and please recommend us to your family and friends 😀
@jiadongyu1312 жыл бұрын
I found myself smiling as I watched this video because your passion and enthusiasm really shone through. Great explanation and good work!
@BackToBackSWE2 жыл бұрын
Great to hear!
@JakealiciousAndBros10 ай бұрын
I’ve been struggling with DSA, but the way you taught this really opened my eyes. I’ll admit, I watched a few parts several times, but I love your energy and will definitely be returning for future problems!
@VickyMei5 жыл бұрын
lol I love how you are so enthusiastic about this :D
@BackToBackSWE5 жыл бұрын
ya
@bn20054 жыл бұрын
thank you for framing this as pointer manipulation instead of "moving nodes" like so many tutorials do
@BackToBackSWE4 жыл бұрын
sure
@nicolerussack98003 жыл бұрын
Idk how you can be so excited talking about recursion but it's making me excited!!!
@Sheldor.The.Conqueror3 жыл бұрын
You explain recursion like no one in their wildest dreams can even think of !!!!
@AndrewWheelerJr4 жыл бұрын
Kind of makes me miss college. I would also get really excited when I finally understood something and was explaining it to someone. Thank you for helping me understand it.
@BackToBackSWE4 жыл бұрын
Sure. great.
@jinhuang72583 жыл бұрын
Explains recursion so well. Thank you.
@maricampbell82404 жыл бұрын
Thank you! The iterative explanation and diagram was so helpful for me. I was able to implement the function without looking at a code example, but from imagining the diagram you created.
@BackToBackSWE4 жыл бұрын
nice
@uditgaba14504 жыл бұрын
saw this video for reversing a linked list recursively . Helped me a lot . Thanks man !
@BackToBackSWE4 жыл бұрын
great - sure
@alhaithamaljabri61264 жыл бұрын
OMG... Thank you so much for your amazing teaching skills! I am happily crying since this finally makes sense to me after all that struggle...
@BackToBackSWE4 жыл бұрын
thanks and nice haha
@serrasilva73163 жыл бұрын
I love your enthusiasm. It makes it so much more fun to learn.
@soujanyayprabhakar4 жыл бұрын
I watched so many explanations regarding this i could not understand but i got an idea about this by watching your video . Kudos !!!
@BackToBackSWE4 жыл бұрын
thanks
@rikki1462 жыл бұрын
bruh this is a treasure on youtube. thank you!
@annawilson3824 Жыл бұрын
10:40 so we have head that points to 3 and new_head(reversedHead) that points to 4. Overall, since each time we have a function call with a new/subsequent head, once we start returning, the head is going to be updated for each call in the reversed order once we propagate back/up the stack, but new_head/reversed will stay the same (we set it value once when we reach the depth of the calls) and always points to 4, so we return it at the end of the whole function.
@pranavbhat929 ай бұрын
The intention & intensity with which you explain is commendable. You deserve more subscribers. I subscribed! 😊
@LesAxolotl3 жыл бұрын
Hey man, thanks for this video. It's such a simple an elegant solution. I spent the last 12 hours trying to solve it myself (not too smart really) and finally gave up and came here. Your explanation is so clear. Cheers!
@aniarablechannel46682 жыл бұрын
Just because you couldn’t solve it doesn’t mean you are “not too smart”. It could just be a difference in coding experience. I wouldn’t get down on yourself. You’re already doing great and setting yourself up for success by working hard to get better and watching videos like this!
@teensymarie3 жыл бұрын
I can only hope that one day I can explain this with as much excitement and clarity as you do.
@zahranajib55284 жыл бұрын
Ahhh please make more videos!!! You are such a lifesaver I swear. Watched your video like 5 times to really understand the concept. Maybe on recursion and more data structures. Also, a suggestion, try to talker slower :)
@BackToBackSWE4 жыл бұрын
Thanks and we will
@anthonysoffice93674 жыл бұрын
you explanation on recursive method was pretty clear
@BackToBackSWE4 жыл бұрын
great glad it helped
@Roover_sa4 жыл бұрын
Brother no words for you . i am stuck at temp->next->next but you nailed it with the example "Let me Add myself" Lot's of love from india
@BackToBackSWE4 жыл бұрын
hey
@eg8162 жыл бұрын
you're so good at explaining!. thanks !!
@BackToBackSWE2 жыл бұрын
Thanks! try out the 5 day free mini course backtobackswe.com/
@alpavaidya4124 жыл бұрын
If I had a teacher as enthu as u bout teaching I would have been better programmer today...appreciate your efforts
@BackToBackSWE4 жыл бұрын
thanks
@roliverma58514 жыл бұрын
Best video on recursion I have ever watched
@anupamdungdung94173 жыл бұрын
Sir the way you give so comprehensive explanation... I love it!
@deepeshrathod20442 жыл бұрын
Damn! this is the best video I found. It just cleared all my doubts for reversing a linked list recursively. Thanks for the video.
@joshj84592 жыл бұрын
Yea I subscribed. You had me on the edge of my seat the entire video like I'm watching a suspenseful movie.
@BackToBackSWE2 жыл бұрын
haha thanks for the sub
@fantasy99602 жыл бұрын
this is the best explanation for listNode reverse! Really appreciate it !!
@yuselina87693 жыл бұрын
Really love your illustration! Thank you!!
@ashwinvarma93494 жыл бұрын
I came here for the recursive method and the explanation was great! keep it up!
@BackToBackSWE4 жыл бұрын
sure
@cf9214 жыл бұрын
This guy explains reversing a linked list like playing basketball with all the shoes' sound lol, love your enthusiasm ;)))
@BackToBackSWE4 жыл бұрын
hey
@spiritualgyanhindi26812 жыл бұрын
Thnx! Finally, I got this logic of returning back after top to bottom😄
@ApexPlayground_divine4 ай бұрын
Bro thanks alot man I final understand this stuff, thanks so much😭
@kanishkarao9793 жыл бұрын
Finally a simple explanation. Thanking God for creating you 😁 😁 😁 😁 😁
@taesookim5315 жыл бұрын
Thank you,, NEXT
@BackToBackSWE5 жыл бұрын
hahahahahahahahahaha. Best comment on this whole channel. I love you.
@HopingforPower Жыл бұрын
One of the more clear explanations of this god forsaken problem. Thank you
@ri7_cars4 жыл бұрын
Thanks, finally understand the recursive solution. The explanation of call stack really helps.
@BackToBackSWE4 жыл бұрын
thanks
@sky765705 жыл бұрын
12:58 Hahaha, explanation with synchronized movements is hilarious bro. Respect.
@BackToBackSWE5 жыл бұрын
ye
@gazalaparveen12542 жыл бұрын
This is literally the best explanation I have come across🙌
@BackToBackSWE2 жыл бұрын
Thank you, glad you liked it 😀 Do check out backtobackswe.com/platform/content and please recommend us to your family and friends 😀
@kevintravelsgram5 жыл бұрын
I thought the recursive way was really confusing so I had to look it up on KZbin. Really glad I found this video. Amazing explanations!
@BackToBackSWE5 жыл бұрын
haha nice, wassup
@cappuccino23455 жыл бұрын
Thanks buddy, I like your explanation better than other's.
@BackToBackSWE5 жыл бұрын
nice
@Mines20134 жыл бұрын
Never seen anyone this excited about reversing a linked list, haha
@BackToBackSWE4 жыл бұрын
I am a lively guy
@supamdeepbains5172 Жыл бұрын
my homie always there to help me with data structures
@himanshusarad64913 жыл бұрын
tysm man ...you literally nailed it with this explanation .....finally i understood how to do this now.
@andywu97744 жыл бұрын
This guy is probably the most passionate CS guy in the entire universe!
@aleman875 жыл бұрын
Very good explanation. I've watched a few of your videos and all of them so far have been easy to follow and does a good job of explaining the approach.
@BackToBackSWE5 жыл бұрын
thanks, welcome to the tribe 🍖
@leetsai62204 жыл бұрын
Watching your explanation and just the passion that you put into these videos really helped me remember the nuances of this problem.
@BackToBackSWE4 жыл бұрын
great
@mingyuetang70415 жыл бұрын
Great explanation!!! gonna use your videos for interview prep. Many thanks 🙇
@BackToBackSWE5 жыл бұрын
great!
@mase-ob1vf2 жыл бұрын
Paid for a DSA course on Udemy and ended up have to KZbin because the explanations were trash. You explained it beautifully and made it incredibly easy to understand. Before finding this video I was dumber than a rock.
@BackToBackSWE2 жыл бұрын
Glad it helped
@jake181119963 жыл бұрын
every one is asking how he is so enthusiastic but my mannnn took a preworkout and he is getting the pre workout kick!!!!
@chamnil86664 жыл бұрын
Thanks Handy Dandy,now i can reverse a linked list,have a blessed day.
@BackToBackSWE4 жыл бұрын
great
@helenashatalova78282 жыл бұрын
Finally, I got it! Thank you so much for your video! Your channel is a hidden jam!
@BackToBackSWE2 жыл бұрын
thanks!
@firstcomesrock85932 жыл бұрын
this is the best explanation of this concept
@BackToBackSWE2 жыл бұрын
Hahaa yay
@annawilson38243 жыл бұрын
Awesome! One thing missing is head.next = null, because that link is not needed anymore.
@anmolsharma95393 жыл бұрын
The time i see that you had made a video on this i know that my doubt is going to get resloved before the video gets over and it happened :)
@samuel23182 жыл бұрын
really love his way to explain this question🤣 he is so enthusiastic and energetic!
@snake1625b5 жыл бұрын
This is why online learning is so much more Superior to in person lectures. In person it would probably go way over your head. But on KZbin you can pause and rewind as many times as you want until it clicks
@BackToBackSWE5 жыл бұрын
haha nice, this video is old and not that good
@snake1625b5 жыл бұрын
@@BackToBackSWE it's pretty good. I still find the recursive part a bit confusing though. I know it's common for employers to ask how to reverse it iteratively but do you think it's common for them to ask to do it recursively?
@Ryan-xb1ry2 жыл бұрын
I finally understand this. Thank you.
@BackToBackSWE2 жыл бұрын
Thank you, glad you liked it 😀 Do check out backtobackswe.com/platform/content and please recommend us to your family and friends 😀
@user-ri7fo6tp5e2 жыл бұрын
Great Teacher man! Finally got the recursion when you could help me visualize going downwards then backup. Thank you man!!
@BackToBackSWE2 жыл бұрын
Thank you, glad you liked it 😀 Do check out backtobackswe.com/platform/content and please recommend us to your family and friends 😀
@fromscratch87744 жыл бұрын
Best Explanation, thank you! I think you have to write the recursive version yourself and draw the nodes to really get it.
@BackToBackSWE4 жыл бұрын
Yes
@iraisvalenzuela6147 Жыл бұрын
Thanks for the video! You simplified this so much for me!
@MaminaZvezdochka3 жыл бұрын
Oh your energy 🔥🔥🔥 I was going to sleep but now I will have a big brain time evening 😆😆😆 thanks so much!
@BackToBackSWE3 жыл бұрын
Haha so glad!
@jacktrainer43872 жыл бұрын
These videos are amazing. You're a phenomenal instructor.
@BackToBackSWE2 жыл бұрын
Thanks man! subscribe to my DSA course for some amazing content b2bswe.co/3HhvIlV
@TadiwanasheNyamapfene5 ай бұрын
Absolutely the best video to explain this. Just took away all my frustration lol!!
@soradev53864 жыл бұрын
It took a while to sink in, but thanks for this detailed explanation to the problem. You killed it
@BackToBackSWE4 жыл бұрын
thx
@kunalkeshavsinghsahni68614 жыл бұрын
Thanks for the beautiful explanation
@BackToBackSWE4 жыл бұрын
sure
@mohanm8556 Жыл бұрын
great explanation....I am able to visualize the recursion while you explain
@BackToBackSWE Жыл бұрын
Thank you, means a lot 🎉 You can also check out our free DSA course - backtobackswe.com/
@skyechapman65953 жыл бұрын
Ah thank you! I'm currently working on this question for school and my dumb mind wanted to approach this by nesting an if inside of a for inside of a while, but trying to find a way to decrement the count lol. Lifesaver!
@raht95783 жыл бұрын
now THAT is how you explain recursion
@jbphoto73 жыл бұрын
Finally! A perfect explanation.
@TCErnesto3 жыл бұрын
I really liked your explanation on the recursive method bro thanks
@niharikayerramsetty85824 жыл бұрын
i have seen many videos but urs is awesome and the best
@BackToBackSWE4 жыл бұрын
thanks.
@acupof_joe3 жыл бұрын
dude this guy is awesome i wish he was my professor
@xingjianwang18944 жыл бұрын
Explanation is crystal damn clear.
@BackToBackSWE4 жыл бұрын
thx
@Polarwhite434 жыл бұрын
Best explanation out there Thanks man
@BackToBackSWE4 жыл бұрын
thanks
@ankurjain83394 жыл бұрын
Such a thorough and simple explanation. Thank you!
@BackToBackSWE4 жыл бұрын
sure
@Bhavin-Desai4 жыл бұрын
Best explanation I have seen so far for reversing a singly linked list .
@BackToBackSWE4 жыл бұрын
thx
@indranilchakraborty59304 жыл бұрын
Love from India..🇮🇳🇮🇳
@BackToBackSWE4 жыл бұрын
thanks
@ExplorerSpace3 жыл бұрын
omg you are a life savior
@Max-zf5ot5 жыл бұрын
How can someone thumbs down this video !!! Amazing effort and urge to explain the solution !!!
@BackToBackSWE5 жыл бұрын
thanks
@joehaynes7092 Жыл бұрын
Had to rewind a lot but first video that worked to understand it :)
@bronzebond48693 жыл бұрын
You do a great job fam. Thousands of us appreciate the help. Thanks again
@ubohllc65875 жыл бұрын
Great Job and great explanation. You take so much effort to explain. Thanks so much!!
@BackToBackSWE5 жыл бұрын
sure
@sanghunlee68252 жыл бұрын
Life saver bro Thanks for your kind explanation
@prathyyyyy3 жыл бұрын
THE BEST VIDEO ON KZbin !!!!!!!! IM IN LOVE :)
@mamoodshaban3119 Жыл бұрын
That was really helpful man. I'm grateful! Keep up with the good work!
@BackToBackSWE11 ай бұрын
Happy Holidays 🎉 Thank you for your kind words! We'd love to offer you a 40% Off our exclusive lifetime membership just use the code CHEER40 - backtobackswe.com/checkout?plan=lifetime-legacy&discount_code=CHEER40
@nuke44962 жыл бұрын
took me sometime for me to digest. thank you.
@pankajmenaria32303 жыл бұрын
best explanation of reverse singly link list
@pankajmenaria32303 жыл бұрын
Do you have any DSA course ?
@labgeek15594 жыл бұрын
love your videos, keep up the great work.
@BackToBackSWE4 жыл бұрын
thanks
@tienduong77292 жыл бұрын
My man big on energy. Love it!
@holyshit9224 жыл бұрын
My way to do it Initialize reversed list //List will be created from existing nodes there is no need for allocating memory for new nodes While original list is not Empty do Pop node from the original list Push node to reversed list return the reversed list
@BackToBackSWE4 жыл бұрын
ok
@sj98512 жыл бұрын
I think it's still not clear enough. Perhaps if you could explained how memory location worked. x = 'value' y = x delete x; y === 'value' // returns true I think many people are confused of what reassignment means here in your algo. For example, what does prev = cur mean in your explanation? Why prev mark is moved to cur loaction when cur is assigned to prev? Many people might think "cur" mark should move to "prev" location in your graph if they don't understand how memory location works.