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
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!
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.
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.
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,
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
Cant get a more dumber explanation of this algorithm...Great job
This dude assumed that the reason I am here is that I didn't know how to read.
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
sir you should not be a teacher
bekar.. who will explain the code for such a algo??
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.
*What's the time complexity for the algorithm ?*
please convert that code in GUI, if is it possible!
Anyone have a solution using min heap or priority queue then please share the link or contribute in any other form.
you should clear problem by example instead of repeating code block
Please share the logic and intuition behind the code and then read the code. Expected much better from gfg
You are just reading the code man!!
Time complexity?
Time complexity??
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!
You mean inorder traversal?
@@rajveersanghvi6678 yeah... My bad
Thanks!
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.
Thanks for the feedback. We will share this with our contributors.
Thanks...
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.
hats off Harshit bro! Successfully wasted lot of my fucking time
*Use MinHeap that's much better*
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,
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
Good jobs just need some support of logic and GFG are always there :)
wasted my time.