Skip to content
Snippets Groups Projects
Commit afa66489 authored by Mirco Dotta's avatar Mirco Dotta
Browse files

Fixed bug: pivot must be placed in the middle of the two sorted list in quicksort method

parent 79cf89bc
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ object QuickSort { ...@@ -28,7 +28,7 @@ object QuickSort {
val (ls,rs) = partition(y => if (y < x) T(y) else F(x), xs) val (ls,rs) = partition(y => if (y < x) T(y) else F(x), xs)
val ls1 = quicksort(ls) val ls1 = quicksort(ls)
val rs1 = quicksort(rs) val rs1 = quicksort(rs)
(x :: ls1) ::: rs1 ls1 ::: (x :: rs1)
} }
def check(xs: List[Int]): Boolean = xs match { def check(xs: List[Int]): Boolean = xs match {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment