Given a sorted doubly linked list and an element X, your need to insert the element X into correct position in the sorted DLL.
X = 9
You only need to complete the function sortedInsert() that takes head reference and x as arguments and returns the head of the modified list. The printing and checking tasks are done by the driver code.
Expected Time Complexity: O(n). Expected Auxiliary Space: O(1).