From 6730444311bcadcc641c3455af21b75fe9b94c97 Mon Sep 17 00:00:00 2001 From: "R.Sathish kumar" <80509559+999sathish999@users.noreply.github.com> Date: Fri, 1 Sep 2023 11:51:44 +0500 Subject: [PATCH] Create LinearSort program having two pointers i and j . In each iteration arr[i] is compared with all other elements arr[ j ] in an array ,if arr[i] is greater than arr[j] ,then the swapping exists. finally the sorted array is printed as a string. --- Java/LinearSort | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Java/LinearSort diff --git a/Java/LinearSort b/Java/LinearSort new file mode 100644 index 0000000..fb5faab --- /dev/null +++ b/Java/LinearSort @@ -0,0 +1,25 @@ +import java.util.Arrays; +public class Main{ +public int[] linearSort(int[] arr){ + + for(int i=0;iarr[j]) { + int temp=arr[i]; + arr[i]=arr[j]; + arr[j]=temp; + } + } + } +return arr; +} +public static void main(String[]args){ + int[] arr={22,44,11,6,12,89,3}; + Main ls=new Main(); + arr=ls.linearSort(arr); + System.out.print(Arrays.toString(arr)); + +} + + +}