-
-
Save 5AbhishekSaxena/f34ce12cc465a8b2c15ad09f0ebfa8f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val numbers = arrayOf(4, 56, 12, 79, 25, 2) | |
sort("Bubble", numbers) | |
} | |
fun sort(algorithm: String, numbers: Array<Int>) { | |
when (algorithm) { | |
"Bubble" -> bubbleSort(numbers) | |
"Merge" -> mergeSort(numbers) | |
else -> throw IllegalArgumentException() | |
} | |
} | |
fun bubbleSort(numbers: Array<Int>) { | |
println("Numbers are sorted using Bubble sort.") | |
} | |
fun mergeSort(numbers: Array<Int>) { | |
println("Numbers are sorted using Merge sort.") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment