Move first node at end of given linked list
The following process to move the first node at end of given linked list
1) initial root pointer is pointing to first node of linked list.
2) help of root pointer visit all other linked list node. and find last node of linked list.
3) Find this last node of linked list assign this address to new pointer variable like(temp variable).And modifying temp->next==NULL to temp->next=root. that means last node of linked list next pointer are initial null that are modified this value to first node of linked list. this is cycle condition there will be removing on step 5.
4) root node pointer value will be modified to next node of linked list.
5) and modifying first node next pointer value is null. note that temp variable are pointed to last of linked list there next node are first node of linked list.
Suppose following data [505, 545, 449, 554, 584, 497, 525, 520, 424, 556] are inserted on linked list.
After move node
Time complexity of this algorithm O(n).
Not given all step of execution process here.View How to insert linked list element, how to print and so on.
c program to move the first node at end of given linked list. Iterative approach.
Case 1: Empty Linked list Empty linked List case 2: When linked list are not empty Before move linked list :550 424 520 525 497 584 554 449 545 505 After move linked list :424 520 525 497 584 554 449 545 505 550 Free nodes of linked linked
- Singly linked list insert data in descending order
- Print middle element in single linked list
- Single linked list print node data at alternate positions
- Delete duplicate data on single linked list
- Single linked list delete any node
- Single linked list delete middle element
- Move middle node at beginning of given linked list