|
5 | 5 | "strings" |
6 | 6 | "time" |
7 | 7 |
|
8 | | - "github.com/gookit/color" |
9 | 8 | "github.com/manifoldco/promptui" |
10 | 9 | ) |
11 | 10 |
|
@@ -125,55 +124,6 @@ func main() { |
125 | 124 | } |
126 | 125 | } |
127 | 126 |
|
128 | | -func printAlgorithmDescription(algorithm int) { |
129 | | - switch algorithm { |
130 | | - case BubbleSort: |
131 | | - color.Bold.Println(color.Yellow.Sprint("Bubble Sort")) |
132 | | - fmt.Println() |
133 | | - fmt.Println(color.Cyan.Sprint("Bubble Sort is a simple comparison-based sorting algorithm. It works by repeatedly stepping through the list to be sorted,")) |
134 | | - fmt.Println(color.Cyan.Sprint("compares adjacent elements, and swaps them if they are in the wrong order. The pass through the list is repeated until the list")) |
135 | | - fmt.Println(color.Cyan.Sprint("is sorted. The algorithm gets its name from the way smaller elements 'bubble' to the top of the list.")) |
136 | | - case SelectionSort: |
137 | | - color.Bold.Println(color.Yellow.Sprint("Selection Sort")) |
138 | | - fmt.Println() |
139 | | - fmt.Println(color.Cyan.Sprint("Selection Sort is an in-place comparison-based sorting algorithm. It works by dividing the input list into two parts:")) |
140 | | - fmt.Println(color.Cyan.Sprint("the sorted part and the unsorted part. The algorithm repeatedly selects the minimum element from the unsorted part")) |
141 | | - fmt.Println(color.Cyan.Sprint("and moves it to the end of the sorted part. This process continues until the entire list is sorted.")) |
142 | | - case InsertionSort: |
143 | | - color.Bold.Println(color.Yellow.Sprint("Insertion Sort")) |
144 | | - fmt.Println() |
145 | | - fmt.Println(color.Cyan.Sprint("Insertion Sort is an in-place comparison-based sorting algorithm. It works by dividing the input list into two parts:")) |
146 | | - fmt.Println(color.Cyan.Sprint("the sorted part and the unsorted part. The algorithm repeatedly picks an element from the unsorted part and inserts")) |
147 | | - fmt.Println(color.Cyan.Sprint("it into the correct position in the sorted part. This process continues until the entire list is sorted.")) |
148 | | - case GnomeSort: |
149 | | - color.Bold.Println(color.Yellow.Sprint("Gnome Sort")) |
150 | | - fmt.Println() |
151 | | - fmt.Println(color.Cyan.Sprint("Gnome Sort is an in-place comparison-based sorting algorithm. It works by repeatedly comparing adjacent elements.")) |
152 | | - fmt.Println(color.Cyan.Sprint("If the two elements are in the wrong order, it swaps them and moves one step backward. If the two elements")) |
153 | | - fmt.Println(color.Cyan.Sprint("are in the correct order, it moves one step forward. This process continues until the entire list is sorted.")) |
154 | | - case CocktailShakerSort: |
155 | | - color.Bold.Println(color.Yellow.Sprint("Cocktail Shaker Sort")) |
156 | | - fmt.Println() |
157 | | - fmt.Println(color.Cyan.Sprint("Cocktail Shaker Sort, also known as Bidirectional Bubble Sort, is a variation of Bubble Sort. It works by repeatedly")) |
158 | | - fmt.Println(color.Cyan.Sprint("sorting the list in both directions, first from the beginning to the end (like Bubble Sort), and then from the end")) |
159 | | - fmt.Println(color.Cyan.Sprint("to the beginning. The algorithm stops when the list becomes sorted.")) |
160 | | - case CombSort: |
161 | | - color.Bold.Println(color.Yellow.Sprint("Comb Sort")) |
162 | | - fmt.Println() |
163 | | - fmt.Println(color.Cyan.Sprint("Comb Sort is an in-place comparison-based sorting algorithm. It works by dividing the input list into a series of")) |
164 | | - fmt.Println(color.Cyan.Sprint("gaps and repeatedly sorting the list with a specific shrink factor. The shrink factor reduces the gaps until it becomes 1.")) |
165 | | - fmt.Println(color.Cyan.Sprint("At this point, the algorithm behaves similar to Bubble Sort. Comb Sort is an improvement over Bubble Sort for large lists.")) |
166 | | - case OddEvenSort: |
167 | | - color.Bold.Println(color.Yellow.Sprint("Odd-Even Sort")) |
168 | | - fmt.Println() |
169 | | - fmt.Println(color.Cyan.Sprint("Odd-Even Sort is an in-place comparison-based sorting algorithm. It works by repeatedly comparing and swapping")) |
170 | | - fmt.Println(color.Cyan.Sprint("adjacent elements at even and odd indices. The process continues until the list is sorted. Odd-Even Sort is known")) |
171 | | - fmt.Println(color.Cyan.Sprint("for its simplicity but is not very efficient for large lists.")) |
172 | | - default: |
173 | | - fmt.Println("Invalid selection") |
174 | | - } |
175 | | -} |
176 | | - |
177 | 127 | func runAlgorithm(algorithm int, arr []int, delay time.Duration) { |
178 | 128 | switch algorithm { |
179 | 129 | case BubbleSort: |
|
0 commit comments