Some error occured while loading page for you. Please try again.
Given a reference to the head of a doubly-linked list and an integer, , create a new DoublyLinkedListNode object having data value and insert it into a sorted linked list while maintaining the sort.
Complete the sortedInsert function in the editor below. It must return a reference to the head of your modified DoublyLinkedList.
sortedInsert has two parameters:
Note: Recall that an empty list (i.e., where ) and a list with one element are sorted lists.
The first line contains an integer , the number of test cases.
Each of the test case is in the following format:
Do not print anything to stdout. Your method must return a reference to the of the same list that was passed to it as a parameter.
The ouput is handled by the code in the editor and is as follows:
For each test case, print the elements of the sorted doubly-linked list separated by spaces on a new line.
1 3 4 5 10
The initial doubly linked list is: .
The doubly linked list after insertion is: