X

DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
QuickSort on Doubly Linked List
Hard Accuracy: 66.85% Submissions: 8986 Points: 8

Sort the given doubly linked list of size N using quicksort. Just complete the partition function using the quicksort technique.
 

Example 1:

Input:
LinkedList: 4->2->9
Output:
2 4 9


Example 2:

Input:
LinkedList: 1->4->9->2
Output:
1 2 4 9


Your Task:
Your task is to complete the given function partition(), which accepts the first and last node of the given linked list as input parameters and returns the pivot's address.

 

Expected Time Complexity: O(NlogN)
Expected Auxilliary Space: O(1)

 

Constraints:
1 <= N <= 200

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

QuickSort on Doubly Linked List

Output Window