Skip to content

Commit

Permalink
Refactor the files and removed the duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
NayakNavin committed Oct 10, 2019
1 parent 1d8d6f8 commit fa849ef
Show file tree
Hide file tree
Showing 30 changed files with 203 additions and 144 deletions.
116 changes: 116 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed BubbleSort-C/BubbleSortC
Binary file not shown.
35 changes: 0 additions & 35 deletions BubbleSort-Java/BubbleSort.java

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
46 changes: 23 additions & 23 deletions InsertionSort.c → C/InsertionSort.c
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# include <stdio.h>
int main(void)
{
int ar[10], key, i, j;
printf ("Enter 10 numbers: \n");
for (i=0; i<10; i++)
scanf ("%d", &ar[i]);
for (i=1; i<10; i++)
{
key = ar[i];
j = i-1;
while (j>=0 && ar[j]>key)
{
ar[j+1] = ar[j];
j = j-1;
}
ar[j+1] = key;
}
printf ("The Sorted array:\n");
for (i=0; i<10; i++)
printf ("ar[%d] = %d\n", i, ar[i]);
return 0;
}
# include <stdio.h>
int main(void)
{
int ar[10], key, i, j;
printf ("Enter 10 numbers: \n");
for (i=0; i<10; i++)
scanf ("%d", &ar[i]);
for (i=1; i<10; i++)
{
key = ar[i];
j = i-1;
while (j>=0 && ar[j]>key)
{
ar[j+1] = ar[j];
j = j-1;
}
ar[j+1] = key;
}
printf ("The Sorted array:\n");
for (i=0; i<10; i++)
printf ("ar[%d] = %d\n", i, ar[i]);
return 0;
}
File renamed without changes.
60 changes: 30 additions & 30 deletions SelectionSort.c → C/SelectionSort.c
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# include <stdio.h>
#define MAX 1000
int main(void)
{
int i, j, N, pos, temp;
int ar[MAX];
printf ("Enter the number of integers to sort:");
scanf ("%d", &N);
printf ("Enter the integers: \n");
for (i=0; i<N; i++)
scanf ("%d", &ar[i]);
for(i=0; i<N-1; i++)
{
pos = i;
for (j=i+1; j<N; j++)
{
if (ar[j]<ar[pos])
{
pos = j;
}
}
temp = ar[pos];
ar[pos]=ar[i];
ar[i]=temp;
}
printf ("The sorted array : \n");
for (i=0; i<N; i++)
printf ("ar[%d] = %d \n", i, ar[i]);
return 0;
}
# include <stdio.h>
#define MAX 1000
int main(void)
{
int i, j, N, pos, temp;
int ar[MAX];
printf ("Enter the number of integers to sort:");
scanf ("%d", &N);
printf ("Enter the integers: \n");
for (i=0; i<N; i++)
scanf ("%d", &ar[i]);
for(i=0; i<N-1; i++)
{
pos = i;
for (j=i+1; j<N; j++)
{
if (ar[j]<ar[pos])
{
pos = j;
}
}
temp = ar[pos];
ar[pos]=ar[i];
ar[i]=temp;
}
printf ("The sorted array : \n");
for (i=0; i<N; i++)
printf ("ar[%d] = %d \n", i, ar[i]);
return 0;
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

public class ImprovedBubbleSort {
public class BubbleSort {
//verifies if the arry is already sorted
//Thus, the best time complexity is improved from O(n^2) to O(n)
static void improvedBubbleSort(int[] arr) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 18 additions & 18 deletions SelectionSort-Python/SelectionSort.py → Python/SelectionSort.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
def selectionSort(l):
for start in range(len(l)):

#assign start value as minimum value
minpos=start

for i in range(start,len(l)):
if(l[i]<l[minpos]):
minpos=i

(l[start],l[minpos]) = (l[minpos],l[start])


if __name__ == "__main__":
print('Enter sequence(separated by spaces): ')
arr=[int(x) for x in input().split()]
selectionSort(arr)
print(arr)
def selectionSort(l):
for start in range(len(l)):

#assign start value as minimum value
minpos=start

for i in range(start,len(l)):
if(l[i]<l[minpos]):
minpos=i

(l[start],l[minpos]) = (l[minpos],l[start])


if __name__ == "__main__":
print('Enter sequence(separated by spaces): ')
arr=[int(x) for x in input().split()]
selectionSort(arr)
print(arr)
Binary file removed SelectionSort-Java/SelectionSort.class
Binary file not shown.
34 changes: 0 additions & 34 deletions quicksorting.java

This file was deleted.

0 comments on commit fa849ef

Please sign in to comment.