Skip to content

Commit ac8f596

Browse files
updating implementation file for all the sorting algo
1 parent a901b28 commit ac8f596

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

Go/sorting/sortingImpl.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package sorting
2+
3+
import "fmt"
4+
5+
func TestSorting() {
6+
var n, choice, result int
7+
fmt.Println("Enter the size of array")
8+
fmt.Scan(&n)
9+
fmt.Println("Enter the array")
10+
arr := make([]int, n)
11+
for i := 0; i < n; i++ {
12+
fmt.Scan(&arr[i])
13+
}
14+
15+
fmt.Println("0: exit 1. Bubble 2. Selection 3. Insertion Sort 4. MergeSort 5. QuickSort 6. CountSort 7. RadixSort")
16+
fmt.Scan(&choice)
17+
18+
switch choice {
19+
case 0:
20+
break
21+
case 1:
22+
result = bubbleSort(arr)
23+
fmt.Println("Swaps: ", result)
24+
break
25+
case 2:
26+
selectionSort(arr, n)
27+
break
28+
case 3:
29+
insertionSort(arr, n)
30+
break
31+
case 4:
32+
mergeSort(arr, 0, n-1)
33+
break
34+
case 5:
35+
quickSort(arr, 0, n-1)
36+
break
37+
case 6:
38+
countingSort(arr)
39+
break
40+
case 7:
41+
radixSort(arr)
42+
break
43+
}
44+
fmt.Println(arr)
45+
46+
}

0 commit comments

Comments
 (0)