Flattening a Linked List | GeeksforGeeks

Sdílet
Vložit
  • čas přidán 22. 10. 2016
  • Explanation for the article: www.geeksforgeeks.org/flatteni...
    This video is contributed by Harshit Jain.

Komentáře • 31

  • @HarshaVardhan-jf9sd
    @HarshaVardhan-jf9sd Před 5 lety +52

    Cant get a more dumber explanation of this algorithm...Great job

  • @divyeshpuri
    @divyeshpuri Před 3 lety +9

    This dude assumed that the reason I am here is that I didn't know how to read.

  • @caligula2167
    @caligula2167 Před 5 lety +11

    Thank you for the video. Hey guys.
    If anyone is struggling with this algorithm, basically what you need to do in order to solve this is:
    1) write a function to merge any two sorted lists
    2) in the function that you will use for flattening, merge the first two nested lists, then merge the third into your list.and so on, to the end of the argument-list.
    Regarding the 2), below is the Python-ish pseudo-code that may help clarify the idea (please do let me know of any bugs that could've snuck in):
    ```
    result = head->down
    node = head->next
    while node is not nil:
    result = merge_lists(result, node->down)
    node = node->next
    ```
    Kind Regards

  • @gallilos
    @gallilos Před 5 lety +25

    sir you should not be a teacher

  • @hardikpatel-90
    @hardikpatel-90 Před 6 lety +6

    bekar.. who will explain the code for such a algo??

  • @bostonlights2749
    @bostonlights2749 Před 4 lety +10

    Dude, at least explain the flow with an example. (You could use the example in the question)
    Otherwise it's just a waste of time.

  • @Mohit-cn2us
    @Mohit-cn2us Před 4 lety +1

    *What's the time complexity for the algorithm ?*

  • @annasbinfazal340
    @annasbinfazal340 Před 6 lety +1

    please convert that code in GUI, if is it possible!

  • @pranaychandra8016
    @pranaychandra8016 Před 5 lety

    Anyone have a solution using min heap or priority queue then please share the link or contribute in any other form.

  • @asthanarht
    @asthanarht Před 5 lety +2

    you should clear problem by example instead of repeating code block

  • @anirudhdevpura2798
    @anirudhdevpura2798 Před 4 lety +1

    Please share the logic and intuition behind the code and then read the code. Expected much better from gfg

  • @SaurabhYadav-hh7fx
    @SaurabhYadav-hh7fx Před 4 lety +1

    You are just reading the code man!!

  • @shivaniguptacv1215
    @shivaniguptacv1215 Před 3 lety

    Time complexity?

  • @dishagupta7446
    @dishagupta7446 Před 3 lety

    Time complexity??

  • @pushangupta4815
    @pushangupta4815 Před 4 lety +1

    If anyone is having a hard time through this algorithm, I have an alternate solution...
    Traverse the given linked list by first visiting all the bottom nodes of each main nodes. As you traverse, make a binary search tree(AVL for better performance) and then do a preorder traversal and see the magic!

  • @shivamguptayoutube
    @shivamguptayoutube Před 2 měsíci

    Thanks!

  • @srinidhibhat3955
    @srinidhibhat3955 Před 7 lety +2

    The explanation is sub-par compared to many of the videos in the play list. I feel it is essential to explain the code with an example thought the video and not just displaying the functions.

  • @AmitRajArtist
    @AmitRajArtist Před 4 lety

    Thanks...

  • @keshavrastogi5005
    @keshavrastogi5005 Před 4 lety +4

    Such a pathetic explanation. Did someone force you to make and upload video. Please don't do it as it waste lot of our time. We trust geeksforgeeks and that's why thought to watch this video.

  • @sahilanower9189
    @sahilanower9189 Před 3 lety

    hats off Harshit bro! Successfully wasted lot of my fucking time

  • @subham-raj
    @subham-raj Před 4 lety

    *Use MinHeap that's much better*

  • @30secondsEmotions
    @30secondsEmotions Před 4 lety

    for all those who are facing difficulty in understand this,
    I want to say that ,sir has explained very nicely,
    ,,but if you want other algorithm,
    you simply make the list linear by joining the vertical list in between two nodes,,,,,two nodes can be node from which it is attached and other node is it's adjacent node, and simply sort it,

    • @30secondsEmotions
      @30secondsEmotions Před 4 lety

      like this,,,,
      like you have a list which you want to flat,
      a function named--
      makeFlattenedList()
      which simple makes the list linear without sorting,,,by joining vertical list in between two nodes of base list
      and after it call the function --
      sortList (),,,
      it will sort the list

  • @adityaaggarwal4622
    @adityaaggarwal4622 Před 4 lety

    Good jobs just need some support of logic and GFG are always there :)

  • @PRIYANKAKUMARI-iz2no
    @PRIYANKAKUMARI-iz2no Před 5 lety +4

    wasted my time.