QuickSort on Doubly Linked List
Submissions: 2707   Accuracy:

59.43%

  Difficulty: Hard   Marks: 8

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.

User Task:
The task is to complete the 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

Explanation:
Testcase 1

** 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.