Sorted insert for circular linked list
Submissions: 17730   Accuracy:

26.7%

  Difficulty: Easy   Marks: 2

Given a sorted circular linked list, insert a newnode so that it remains a sorted circular linked list.

Input:

In this problem, method takes two argument: the address of the head of the linked list and the data which you have to insert. The function should not read any input from stdin/console.
The Node structure has a data part which stores the data and a next pointer which points to the next element of the linked list. 
There are multiple test cases. For each test case, this method will be called individually.

Output:
Set the * head_ref to head of resultant linked list.

Note: If you use "Test" or "Expected Output Button" use below example format

Constraints:

1<=T<=100
0<=N<=200

Example:

Input:
2

3                           Size of Linked List
1 2 4
                    Elements of Linked List
2
                           Element to be inserted
4

1 4 7 9
5

Output:

1 2 2 4
1 4 5 7 9

** For More Input/Output Examples Use 'Expected Output' option **

Author: bhawnamait


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.