Skip to content

Commit 83bac88

Browse files
committed
Initial Commit
1 parent 80f2841 commit 83bac88

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

Java/Bubble_Sort.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.util.Arrays;
2+
3+
public class Bubble {
4+
public static void main(String[] args) {
5+
int[] myarr = {34, 23, 34, 2, 3, 8, 4, 5};
6+
BubbleSort(myarr);
7+
System.out.println(Arrays.toString(myarr));
8+
}
9+
10+
public static void BubbleSort(int[] arr){
11+
for(int i = arr.length - 1; i > 1; i--){
12+
for(int j = 0; j < i; j++){
13+
if(arr[j] > arr[j+1]){
14+
int temp = arr[j];
15+
arr[j] = arr[j+1];
16+
arr[j+1]= temp;
17+
}
18+
}
19+
}
20+
}
21+
}

Python/Selection_Sort.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def sortSelection(inputList):
2+
for i in range(len(inputList)):
3+
min = i+1
4+
for j in range(i, len(inputList)):
5+
if(inputList[j] < min):
6+
min = j
7+
temp = inputList[i]
8+
inputList[i] = inputList[j]
9+
inputList[j] = temp
10+
return(inputList)
11+
12+
a = [4, 3, 2, 5]
13+
print(sortSelection(a))

0 commit comments

Comments
 (0)