Learn basic concept of c , c++ and python programming in regularcodes.com
Move middle N node in beginning of linked list
Suppose linked list contain following nodes [ 1, 2, 3, 4, 5, 6, 7, 8 ,9, 10 ]. Our goal is to Move middle N nodes in beginning of linked list.
The following cases are follow of this problem.
Case 1 : first and last node are not a part of middle nodes. Example linked list contain 3 nodes [1,2,3]. and there are only one middle . if user are given to move 2 middle node to front of linked list then it is not possible.
Case 2 : if two set of middle node then move first set of front of linked list. example [1,2,3,4,5] if move 2 middle nodes. then possible to sets A [2,3] and B[3,4]. in this case move first set.
View pointers and nodes.
Example 1: Move middle 6 nodes.
After move middle 6 nodes.
C program to Move Middle N nodes at front of linked list . Iterative approach.
- Insertion of single linked list
- Singly linked list insert data in ascending order
- Single linked list insert node at middle position
- Print middle element in single linked list
- Move the first node at end of given linked list
- Move first node a middle of given linked list
- Move first node at given position in linked list
- Move middle N node in beginning of linked list