Skip to main content

Program to print items in single linkedlist in Pendulum order 

Single linked list pendulum in java

There are sequence of numbers in a single linked list and display the result in pendulum format

Input: 1 2 3 4 5 6 7 8

Output: 1 8 2 7 3 6 5 4

Solutionhttps://github.com/Bonu/datastructures/blob/main/SingleLinkedListPendulum.java

Below is the manual approach:
Input: 1 2 3 4 5 6 7 
Iteration 1: 1   2   3 4 5 6 7
Iteration 2: 1 7 2   3 4 5 6
Iteration 3: 1 7 2 6 3 4 5
Iteration 4: 1 7 2 6 3 5 4

Comments