Learn basic concept of c , c++ and python programming in regularcodes.com
Inserted Linked list data in Ascending order (sorted order)
Inserting linked list element in ascending (sorted order). We Discussing about all test cases. Following data [44, 35, 34, 75, 23, 36, 66, 62] are inserting into linked list.
Case 1: No element in linked list then insert first node of linked list. Suppose insert node 44.
Case 2: If insert data value less then and equal to root pointed value then insert node at starting position. Suppose insert node 35.
Onother example insert newly data 34.
View this execution process.
Case 3: If insert node are big then insert those node at end of linked list. insert element 75.
Insert element 23. That are follow case 2.
Case 4: Special case when insert newly created node at between of linked list nodes.
Insert element 36.
Insert element 66.
insert node 62.
Given Below execution process
In this execution process not imagination all steps. below link click and view how to insert linked list node, how to show all linked list node and free all linked list element.
Time complexity of this program O(n)
C program to insert linked list node in ascending order.
Case 1: Empty Linked list Output Empty linked List case 2: When linked list are not empty Output Linked list data is : 23 34 35 36 44 62 66 75 Free linked list Node element