From 0fbce19201ec8d2a6e7b3ea98256a617054c0fe1 Mon Sep 17 00:00:00 2001 From: venkatabhaskar Date: Sat, 2 Oct 2021 12:09:42 +0530 Subject: [PATCH] some sorting algorithms are added in java language --- .DS_Store | Bin 0 -> 6148 bytes Algorithms/.DS_Store | Bin 0 -> 6148 bytes Algorithms/java/.DS_Store | Bin 0 -> 6148 bytes Algorithms/java/sorting/BubbleSort.java | 34 +++++++++++++++++ Algorithms/java/sorting/CyclicSort.java | 35 +++++++++++++++++ Algorithms/java/sorting/InsertionSort.java | 38 +++++++++++++++++++ Algorithms/java/sorting/SelectionSort.java | 42 +++++++++++++++++++++ 7 files changed, 149 insertions(+) create mode 100644 .DS_Store create mode 100644 Algorithms/.DS_Store create mode 100644 Algorithms/java/.DS_Store create mode 100644 Algorithms/java/sorting/BubbleSort.java create mode 100644 Algorithms/java/sorting/CyclicSort.java create mode 100644 Algorithms/java/sorting/InsertionSort.java create mode 100644 Algorithms/java/sorting/SelectionSort.java diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..39b12dcaa02412729d83b0beac6fa471c82fb5f6 GIT binary patch literal 6148 zcmeHK&2G~`5S~p#YX?>2fJ84yzHqCmw1r9>DmiI#hy(~>1P4H^T}O>2*IW6A2tttW zJOR7}&%qP$IPmQcRh_g~gwTvM`_0bIXUm`0yIvv^gDT!7>JpIySJ-mVTw`in`HHn{ zW*sQ>HF8R*q$!#|6;t5LLzD}}O&IYo|;zD01FawU`I_`0IYd+sQ=xuxZk9v!3Z~k}> z@x%Rt#lm&&J=i@QpPYaAIRCWx{8c{=2~1#ZcP##aZwRgx=zWl9sm#tWuDF{tq!5!o zqyTMB6`cYrM3W^czoYu9lpFMf#&kp@dIs*OSuO4_RlD>8m3`dpDR2j$TD-*gvcy1_ zjTK-8Sb?SjcFA*YH`Cl>1y})AK>yZw&_S&ezQx+0UOLd|BLJ|Cv^K=*cTsUXi@wF$ zAVy%qP=SUj>=8p4I`W>a^DWi}4V{ENd|*4Rp2)UYl&3= literal 0 HcmV?d00001 diff --git a/Algorithms/.DS_Store b/Algorithms/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ce968b7f17d3cd91180846796f2ad1c54499c3be GIT binary patch literal 6148 zcmeHK%}&EG40g5w*$`p}BsliM353S4!~v-cIB-KMf&-wfWfK&Y25lV^jG?{;yadm| z6Yw}-C)uPicI8jDATeW3?A^=EK!b~2UFNDTPha_V?IYdEosPiCF z0rqG*mcPINeY-52!vZYqM+4t)8%LJjwdjT9;0k=W1^-jr%c!`Z-Mq2?!)tI8h0UZ? zdJ~y!Zftx)%7QFR70$d%)%FrUX*J7!MlB+%@wrQRyVrcyquk1 z-rBET-`#f}x{ptKsUYxo)-r9e2hV8qiMaI|airo4^!4I1I)lrFhKi*gG%UHObzO-0~=ieAksBb3)=efkLZvC(Y2TwL=TEEsfZ?3*b+n7 z+Ci9f9CvMeYS5&E&`-vB?30D9P=qZ#grmbjxCXgp2AF|C2C}AGr1O7obp1b=#64z! z8TeNWh}^EXTgD~Xvvp{3bk;hkRa6p+OAYo@(9lOQ#?nzdhpGkr4jG89#nd2rQ1~LC MY2bz#_*Mo!0E;MO{{R30 literal 0 HcmV?d00001 diff --git a/Algorithms/java/.DS_Store b/Algorithms/java/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..edae0d95c3d0ababa86ee75aa897068629a7726e GIT binary patch literal 6148 zcmeHK%}T>S5T32oZYyFBf*y16Ceo^i9)uY6;7y3=K}8c=Y9MB%NiA9{c@2FdpTNh_ zncc0Z)uUo%24=s>{A{vc!fpltgx6`*0jdBXQ3(rW9KH~WlMYG2dd3iio+E+;TD!42 z596V1cKk&K=-rhd1qE%$;NAOEAx7x4*hF1?(Sp`ccGyj?!dPcNg;#NuX0_V0D2x@y zCrVOQWM!&y;$Nt)p9NVb^@8>hUF`+gMQH7PrQ$a`2oIuW_p~~*rIIX&l4e^MM~x%;76-v+Ts8n(fCBlwck!+m9#K2s2XH5G6T#2Gca-t*o{n1j@*;;12Y56 zz)v$k`-6i@=vvGT>a7C@-2xyM(X9n-`e~#Z$D(U7H;54wVM-BAsjw}EFy-iXY@TZ| zH)zU1*ycmnI}6*P2z_^)-_hwHT!TC^1I)lj2B`N#snYqs^L_uXlXzeTn1TPvfGBSJ z+a9jXo~=Wxq_fsRJwqj-yxibh2^#t+##}mz=TNnv-ys9hwU`@34+{SXXc~B627Z-+ ESLEeif&c&j literal 0 HcmV?d00001 diff --git a/Algorithms/java/sorting/BubbleSort.java b/Algorithms/java/sorting/BubbleSort.java new file mode 100644 index 0000000..d930825 --- /dev/null +++ b/Algorithms/java/sorting/BubbleSort.java @@ -0,0 +1,34 @@ +import java.util.Arrays; +import java.util.Scanner; + +public class BubbleSort { //For Ascending order. + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n; + n=sc.nextInt(); + int[] arr = new int[n]; + for(int i=0;iarr[j]) + { + int temp; //swapping + temp=arr[j]; + arr[j]=arr[j-1]; + arr[j-1]=temp; + } + } + } + } + +} diff --git a/Algorithms/java/sorting/CyclicSort.java b/Algorithms/java/sorting/CyclicSort.java new file mode 100644 index 0000000..bfc6525 --- /dev/null +++ b/Algorithms/java/sorting/CyclicSort.java @@ -0,0 +1,35 @@ +import java.util.Arrays; +import java.util.Scanner; + +public class CyclicSort { /**cyclic sort varies with the given range of numbers in the + array this algorithm is for [0 , N-1] and the size of array is 'N' **/ +public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n,k=0,temp; + n= sc.nextInt(); + int[] arr = new int[n]; + for(int i=0;i0;j--) + { + if(arr[j]