Clausal Language (ver. 5.81.16, by P.J. Voda, J. Komara, J. Kluka)
9. CVIČENIE Z PREDMETU ÚVOD DO DEKLARATÍVNEHO PROGRAMOVANIA
http://ii.fmph.uniba.sk/cl/courses/1-AIN-505-udp/0506ls/ex/ex09.cl
|
|
Dátum: utorok 11. 4. 2006
Odporúčaná verzia CL: 5.81.16
WWW stránka predmetu: http://ii.fmph.uniba.sk/cl/courses/1-AIN-505-udp/0506ls/?lang=sk
Kontakt na cvičiaceho: mailto:kluka@fmph.uniba.sk
|
|
Preskočte nasledujúce komponenty až po nadpis "CVIČENIA".
|
|
Exercise 1. Define a predicate
which holds if
is an increasingly ordered list:
|
|
Definition. A list can be sorted by a function
satisfying:
(see the lecture).
In the next exercises, you will implement the following
methods of sorting:
-
insertion sort by a function
,
-
merge sort by a function
, and
-
quicksort by a function
.
We shall use the auxiliary functions
[
;
] and
[
;
] to describe required properties of some functions below. However, you must
not use these functions.
|
|
Exercise 2. Implement the insertion sort in the following steps:
-
Define a function
satisfying:
-
Using the function
define the function
which orders the list
and satisfies:
Do not use other auxiliary functions (nor the predicate
).
Caution. This functions is different from, though
similar to, the function
from part I of this file.
|
|
Exercise 3. Implement the merge sort in the following steps:
-
Define first a function
satisfying:
-
Define next a function
satisfying:
-
Finally, using
and
define the function
which orders the list
:
Do not use other auxiliary functions (nor the predicate
).
|
|
Exercise 4. Implement the quicksort in the following steps:
-
Define a function
satisfying:
-
Use the function
in the definition of the function
which orders the list
:
Do not use other auxiliary functions (nor the predicate
).
|
|
Heap used: 215528 free: 134001488
Time used: 0:0:0:6