Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uva
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
uva
Commits
1f71a51d
Commit
1f71a51d
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
funclang series4: Improved quickSort.
parent
cf3cb8a8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
funclang-taddeus/series4/ass8.ml
+7
-4
7 additions, 4 deletions
funclang-taddeus/series4/ass8.ml
with
7 additions
and
4 deletions
funclang-taddeus/series4/ass8.ml
+
7
−
4
View file @
1f71a51d
open
List
(* Sort a list l using the quicksort algorithm *)
let
rec
quickSort
(
l
:
int
list
)
=
match
l
with
|
([]
|
[
_
])
->
l
|
pivot
::
rest
->
let
rec
assign
low
high
l
=
let
cmp
x
=
x
<
pivot
in
let
low
,
high
=
partition
cmp
rest
in
quickSort
low
@
pivot
::
quickSort
high
(*let rec assign low high l =
match l with
(* Assigning elements is done, sort the lower and higher sublists
* individually and concatenate them with the pivot *)
...
...
@@ -13,11 +18,9 @@ let rec quickSort (l:int list) =
| h::t -> if h <= pivot then assign (h::low) high t
else assign low (h::high) t
in
as
s
ign
[]
[]
rest
asign [] [] rest
*)
;;
open
List
(* Sort a list l using the merge sort algorithm *)
let
rec
mergeSort
(
l
:
int
list
)
=
match
l
with
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment