Created
October 15, 2022 07:51
-
-
Save aerphanas/6fa999a75c15323b0cac5c2d8d3acf3b to your computer and use it in GitHub Desktop.
c++ and haskell Quick short
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
| void quickSort(int arr[], int start, int end) | |
| { | |
| if (start >= end) return; | |
| int p = partition(arr, start, end); | |
| quickSort(arr, start, p - 1); | |
| quickSort(arr, p + 1, end); | |
| } |
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
| quicksort :: (Ord a) => [a] -> [a] | |
| quicksort [] = [] | |
| quicksort (x:xs) = | |
| let smallerSorted = quicksort (filter (<=x) xs) | |
| biggerSorted = quicksort (filter (>x) xs) | |
| in smallerSorted ++ [x] ++ biggerSorted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment