From f816f5955c3c784d7c79f700dcfd8131b84c701d Mon Sep 17 00:00:00 2001 From: SINJINI HOM ROY <87771678+Sinjini46@users.noreply.github.com> Date: Wed, 6 Oct 2021 11:27:49 +0530 Subject: [PATCH] PendulumWiseSortingofArray --- PendulumWiseSortingofanArray.java | 83 +++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 PendulumWiseSortingofanArray.java diff --git a/PendulumWiseSortingofanArray.java b/PendulumWiseSortingofanArray.java new file mode 100644 index 0000000..5e0062e --- /dev/null +++ b/PendulumWiseSortingofanArray.java @@ -0,0 +1,83 @@ +import java.util.*; +class pendulum +{ + int a[]; + int n; + pendulum() + { + n=0; + } + void accept() + { + Scanner sc=new Scanner(System.in); + System.out.println("enter the limit"); + n=sc.nextInt(); + a=new int[n]; + System.out.println("enter the values"); + for(int i=0;ia[j + 1]) + { + int t=a[j]; + a[j]=a[j+1]; + a[j+1]=t; + } + } + } + } + void check() + { + int r[]=new int[n]; + int f=(n/2)+1; + int l=(n/2)-1; + r[n/2]=a[n-1]; + int k=0; + for(int i=n-2;i>=0;i--) + { + if(k==0) + { + r[f]=a[i]; + f++; + } + else + { + r[l]=a[i]; + l--; + } + k=-k+1; + + + } + for(int i=0;i