Skip to content

Commit 94acf5f

Browse files
Merge pull request #462 from Akshit312/master
Create Sort Nearly sorted array
2 parents 2c20f3e + 9c81ec7 commit 94acf5f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Gcd.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Test {
2+
3+
static int gcd(int a, int b)
4+
{
5+
if (b == 0)
6+
return a;
7+
return gcd(b, a % b);
8+
}
9+
10+
// Driver method
11+
public static void main(String[] args)
12+
{
13+
Scanner sc=new Scanner(System.in);
14+
int a=sc.nextInt(),b=sc.nextInt();
15+
System.out.println("GCD of " + a +" and " + b + " is " + gcd(a, b));
16+
}
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
static void insertionSort(int A[], int size)
2+
{
3+
int i=0, k=0, j=0;
4+
for (i = 1; i < size; i++)
5+
{
6+
k = A[i];
7+
j = i-1;
8+
while (j >= 0 && A[j] > k)
9+
{
10+
A[j+1] = A[j];
11+
j = j-1;
12+
}
13+
A[j+1] = k;
14+
}
15+
}

0 commit comments

Comments
 (0)