Question: Write a function to insert a value into dynamically allocated sorted singly-linked list. If the list is empty, place the item in the first node
Write a function to insert a value into dynamically allocated sorted singly-linked list. If the list is empty, place the item in the first node of the list. Assume the list is sorted in ascending order. The function should return a pointer to the first node of the resulting list
Assume listNode and the function prototype are defined as follows: please write the code by using java language only
| Java: class listNode { public int dataValue; public listNode next; };
prototype: public static listNode* insert(listNode* first, int item); |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
