File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments