Software interview question - Reverse a linked list recursively

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ส.ค. 2019
  • In this video we learn how to reverse a singly linked list recursively. This algorithm is a little tricky so we break it down using a visual diagram.

ความคิดเห็น • 71

  • @user-nb1fx7fo3l
    @user-nb1fx7fo3l 10 วันที่ผ่านมา

    Finally I understand the recursive method with this video after I spent a whole day digging through tons of other learning materials on the web.

  • @grindinglcmeow
    @grindinglcmeow 4 หลายเดือนก่อน

    The animation is a super clean explanation to the `node-->next->next` confusion!! Big thanks mate.

  • @akihana4113
    @akihana4113 3 ปีที่แล้ว +14

    This is the best reverse linked list in recursive tutorial I've ever seen.

  • @paragnaik9826
    @paragnaik9826 3 ปีที่แล้ว +4

    truly underrated video...explains recursion clearly

  • @ustunkaya
    @ustunkaya ปีที่แล้ว +6

    This is a very articulate explanation, thanks Jesse. Making something look so simple is an art.

  • @carefree_ladka
    @carefree_ladka 11 หลายเดือนก่อน

    Finally understood the recursive approach. Thanks a lot

  • @ledinhanhtan
    @ledinhanhtan ปีที่แล้ว

    I feel relieved after what your explanation. Thank you!

  • @urrahman196
    @urrahman196 3 ปีที่แล้ว +1

    this is the best so far on recursion, thanks a lot buddy. Very intuitive.

  • @ikrenji8125
    @ikrenji8125 2 ปีที่แล้ว

    excellent. the tricky part for me was understanding node.next, but this video cleared it up

  • @rochelleroberts5837
    @rochelleroberts5837 3 ปีที่แล้ว

    Thanks for spending extra time explaining node.next.next = node. I really appreciated you breaking it down! Thanks again.

  • @sahilrizvi3039
    @sahilrizvi3039 3 ปีที่แล้ว

    Love you bro ❤️❤️, after wasting 3hrs i finally understand how this Work.

  • @acca1461
    @acca1461 5 ปีที่แล้ว +2

    I like your explanations before implementing the algorithms

  • @jaidaayasser1260
    @jaidaayasser1260 ปีที่แล้ว

    The best explanation! I wish all linkedList problems are solved like that! You're the best Thank you

  • @karimmessaoud8223
    @karimmessaoud8223 2 ปีที่แล้ว

    Very good explanation of all the algorithms episodes. Thank you! Next would be welcome.

  • @sanjeevchopra2381
    @sanjeevchopra2381 3 ปีที่แล้ว

    He has expained the concept the best way. others were confusing . I am talking about whole of Internet. I want to know why one person has disliked the video.

  • @444brando
    @444brando 3 ปีที่แล้ว

    The detail and clarity in this video was perfect!

  • @Jgrabow1985
    @Jgrabow1985 2 ปีที่แล้ว

    Oh my god. This is actually the best explanation of any algorithm I think I have ever seen. You should really do more!

  • @RSWDev
    @RSWDev ปีที่แล้ว

    I finally understood the recursive solution after watching your video. In one sentence: the sub-problem is setting the next node's next the current node, and then setting the current node's next to null.

  • @abhinav8385
    @abhinav8385 ปีที่แล้ว

    thank you so much! saw tons of videos on net, still no use. after hours & hours of finding found it!

  • @parmeetsingh2479
    @parmeetsingh2479 3 ปีที่แล้ว +1

    I saw many explanations but this is my favorite 🙌
    Explained amazingly 👏

  • @TheMustafa5233
    @TheMustafa5233 ปีที่แล้ว

    Thank you for this; all lighted up @ 9:25

  • @Oliver-nt8pw
    @Oliver-nt8pw 6 หลายเดือนก่อน

    This is a very good video! Really helped me to understand!

  • @santhoshkumarrajan4963
    @santhoshkumarrajan4963 ปีที่แล้ว

    Loud and Clear! Thanks for the explanation!

  • @horaciocastillodelrio5967
    @horaciocastillodelrio5967 3 ปีที่แล้ว

    Damn this is the only video that explains the whole thing!! Thank You Man!

  • @lennythach607
    @lennythach607 2 ปีที่แล้ว

    Absolutely Brilliant! Keep making these videos Jesse!

  • @tanmayasamaltk64
    @tanmayasamaltk64 3 ปีที่แล้ว

    The best explanation is here. I can guarantee that student will have no fear of recursion after watching this love ❣️from my side.

  • @StyleBySabina
    @StyleBySabina 3 ปีที่แล้ว

    Perfect explanation! Finally understood reversing a linked list, thank you!

  • @krishnavishwakarma9062
    @krishnavishwakarma9062 3 ปีที่แล้ว

    Thank you brother... I have cleared my doubt through this video.. 🙃

  • @akhilr94
    @akhilr94 ปีที่แล้ว

    Finally! This is what I needed. Thank you so much.
    I used to think, once 5 is returned by last fn call, ie reverseList(4) why can't we do head.next = node. But that'd only result in [5,4], [5,3],etc for each call. Even if I make it work, which is possible. By the end of all calls, I will not have the new head of the reversedList altho the list might be reversed.
    This video helped me understand that we are return 5 all the way back to the first call. That is the gotcha for this algo in my opinion.

  • @michaelgreim5000
    @michaelgreim5000 3 ปีที่แล้ว

    This is the only video that made sense to me. Thanks so much!

  • @lukeguan1397
    @lukeguan1397 4 ปีที่แล้ว +2

    That is an amazing explanation.

  • @baothach9259
    @baothach9259 9 หลายเดือนก่อน

    Excellent video!!!

  • @muhisaleh4598
    @muhisaleh4598 ปีที่แล้ว

    thnx a lot :)) finally i got this recursion !!!!!!!!

  • @chiefsittingstill6061
    @chiefsittingstill6061 3 ปีที่แล้ว

    Grand job, thanks. The visualisation of the logic in Powerpoint really helps, but for me it was the crystal clear explanation of what node->next->next = node (to use the C++ syntax) is doing, a line of code that seems mystifying at first, that really clinched it.

  • @phanmarreddy579
    @phanmarreddy579 ปีที่แล้ว

    really nice visualization !!!!

  • @jacklo32
    @jacklo32 10 หลายเดือนก่อน

    amazing explanation !

  • @kunpeng8646
    @kunpeng8646 4 ปีที่แล้ว

    Thanks for sharing, what a fantastic job you did!

  • @milesl577
    @milesl577 ปีที่แล้ว

    Your video is very helpful

  • @tiennguyenthuy7563
    @tiennguyenthuy7563 2 ปีที่แล้ว

    Very helpful. Thank you

  • @stealth1726
    @stealth1726 3 ปีที่แล้ว +3

    Hey Jesse, just wondering if your planning on releasing anymore videos or courses, as they are incredibly helpful, thanks for the great content.

  • @erichubbard4569
    @erichubbard4569 3 ปีที่แล้ว

    THANK YOU. I didnt understand that it returns five to the previous caller, I didnt even know that was a thing.

  • @swapnil1175
    @swapnil1175 4 ปีที่แล้ว

    THANK YOU.....it was really helpful

  • @fredflintstone8048
    @fredflintstone8048 5 ปีที่แล้ว

    Excellent!

  • @abdullokhalimov2012
    @abdullokhalimov2012 2 ปีที่แล้ว

    Thank you a lot!

  • @chien-yucode992
    @chien-yucode992 4 หลายเดือนก่อน

    Nice!

  • @saeedmirzaei1
    @saeedmirzaei1 3 ปีที่แล้ว

    I appreciate!

  • @stanleylew1688
    @stanleylew1688 10 หลายเดือนก่อน

    Thanks! 🙏

  • @German-ov9de
    @German-ov9de ปีที่แล้ว

    Subscribed

  • @andjelaarsic9217
    @andjelaarsic9217 ปีที่แล้ว

    Thanks!

  • @abhisheksuryavanshi9675
    @abhisheksuryavanshi9675 3 ปีที่แล้ว

    Ladies and Gentlemen, now that's how you explain reversing a linked list using recursion

  • @carsten2600
    @carsten2600 10 หลายเดือนก่อน

    OMG ur legend!

  • @VinuP2023
    @VinuP2023 5 ปีที่แล้ว

    Thanks much

  • @tianyiwang4820
    @tianyiwang4820 3 ปีที่แล้ว

    thanks

  • @jamesrockybullin5250
    @jamesrockybullin5250 4 ปีที่แล้ว +1

    I'm very new to linked lists and recursion, but returning the new Head value recursively through all the nodes seems pretty wasteful/inefficient. Surely the whole point of a linked list is that a middle node, say node3, does not need to be concerned with where the list starts or ends?
    I did it the same way because the question said to do it recursively. But, in the real world, would you determine the new Head iteratively? This would simplify the recursive method and it seems to me like it would make the code run a bit faster. Would it? Or is it better to stick all of the functionality in one place and do everything recursively?

    • @girirajrdx7277
      @girirajrdx7277 2 ปีที่แล้ว

      recurssion does the work only on its way back....while linked list being manipulated we are also doing the return of new head with it....complexity may be at 2n which is just O(n) (which is also for a iteration)

  • @abhishek-kapoor
    @abhishek-kapoor 4 ปีที่แล้ว

    thx

  • @nicholasmciver5932
    @nicholasmciver5932 4 ปีที่แล้ว

    You Should Do a tutorial on Linq and LinqPad

  • @Blowyourspot747
    @Blowyourspot747 3 ปีที่แล้ว

    For the algo

  • @theashero
    @theashero 4 ปีที่แล้ว

    Hi Jesse,
    Could you please share the book name and writer name which you referred while uploading the videos for Exam 70-483. I love those videos and going through them and will soon give the exam.
    Thank You So Much for all your videos.

  • @ScitechExplorerEnglish
    @ScitechExplorerEnglish 2 ปีที่แล้ว

    Hi sir I have questions : how can we declare a delegate for an overloaded method

  • @sheebanwasi6116
    @sheebanwasi6116 3 ปีที่แล้ว

    ​ hey I understood most of the part but I am really confused how the 5 remains in the variable head. For example: head = reverse(node.next); node.next.next = node, node.next = null, return head. The caller when reached 5 it returned 5 now the head variable has the value 5 when the caller returned back to 4 but when the caller returned back to 3 why not the head value is updated with 4?? Hope you got my question. Thanks in advance

  • @farisal_homsi4826
    @farisal_homsi4826 5 ปีที่แล้ว

    Jesse, Jesse, we have to cook, ah I mean code

  • @poikilotherm5611
    @poikilotherm5611 ปีที่แล้ว

    😀

  • @syedhassanfarman3566
    @syedhassanfarman3566 4 ปีที่แล้ว

    Are you goin to complet Exam 70-483: Programming with C# series ?

  • @antonsemenov7176
    @antonsemenov7176 2 ปีที่แล้ว

    not clear explanation

  • @waiyanleung5199
    @waiyanleung5199 4 ปีที่แล้ว +42

    Finally I understand the recursive method with this video after I spent a whole day digging through tons of other learning materials on the web.

    • @iam_tigress
      @iam_tigress 3 ปีที่แล้ว +3

      same here!! I watched videos until I found this gold right here! I GOT IT NOW. Thank you Jesse!!!

    • @mobiledeveloper6068
      @mobiledeveloper6068 3 ปีที่แล้ว +2

      I also spent all-day digging through materials. even try to trace every step in my code and I am still confused until this video. 10:30 - 10:40 is all I need...I think 99% of people just pretend they understand this simple algorithm that is why they can't really explain it.

    • @sheebanwasi6116
      @sheebanwasi6116 3 ปีที่แล้ว

      ​@@mobiledeveloper6068 hey I understood most of the part but I am really confused how the 5 remains in the variable head. For example: head = reverse(node.next); node.next.next = node, node.next = null, return head. The caller when reached 5 it returned 5 now the head variable has the value 5 when the caller returned back to 4 but when the caller returned back to 3 why not the head value is updated with 4?? Hope you got my question.

    • @sheebanwasi6116
      @sheebanwasi6116 3 ปีที่แล้ว +1

      @@iam_tigress ​ hey I understood most of the part but I am really confused how the 5 remains in the variable head. For example: head = reverse(node.next); node.next.next = node, node.next = null, return head. The caller when reached 5 it returned 5 now the head variable has the value 5 when the caller returned back to 4 but when the caller returned back to 3 why not the head value is updated with 4?? Hope you got my question.

    • @sheebanwasi6116
      @sheebanwasi6116 3 ปีที่แล้ว

      hey I understood most of the part but I am really confused how the 5 remains in the variable head. For example: head = reverse(node.next); node.next.next = node, node.next = null, return head. The caller when reached 5 it returned 5 now the head variable has the value 5 when the caller returned back to 4 but when the caller returned back to 3 why not the head value is updated with 4?? Hope you got my question.