Insert value in sorted way in a sorted doubly linked list

Given a Sorted Doubly Linked List in ( non-decreasing order ) and an element x , the task is to insert the element x into the correct position in the Sorted Doubly Linked List.

Example:

Input: LinkedList = 3581012 , x = 9
Output: 35891012

Insert-in-Sorted-way-in-a-Sorted-DLL-2

Explanation: Here node 9 is inserted between 8 and 10 in the Doubly Linked-List.

Input: LinkedList = 141011 , x = 15
Output: 14101115

Insert-in-Sorted-way-in-a-Sorted-DLL-4

Explanation: Here node 15 is inserted at end in the Doubly Linked-List.

Approach :

                                                                                                                                                                           C
                                                                                                                                                                                     Java
                                                                                                                                                          Python
               C#
                                                                                                                                                                                    JavaScript

Output
3 5 8 9 10 12

Time Complexity: O(n) , where n is the number of nodes in the linked lsit.
Auxiliary Space: O(1)