QuickSort on Doubly Linked List
Submissions: 1673   Accuracy:

53.94%

  Difficulty: Hard   Marks: 8
Associated Course(s):   Interview Preparation

Sort the given doubly linked list using quicksort. Just complete the partition function using quicksort technique try to solve it in O(1) space .

Input:

In this problem, method takes two argument: the node1 and node2. The function should not read any input from stdin/console.
The struct Node has a data part which stores the data and a next pointer which points to the next element of the linked list.
There are multiple test cases. For each test case, this method will be called individually.


Output:

Return p from function.

Constraints:
1<=T<=100
1<=N<=200

Example:

Input:

2
3
4 2 9
4
1 4 9 2

Output:

2 4 9
1 2 4 9

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Amit Khandelwal
Author: bhawnamait


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.