![]() |
.. (לתיקייה המכילה) | |
(Q3) Is there any significance to the order in which subsets are shown in the predicate powerset?
|
No. This means, for example, that: a. both powerset([1,2],[[],[1],[2],[1,2]]) and powerset([1,2],[[],[2],[1],[1,2]]) should come out provable b. when answering a query like powerset([1,2,3],Y), the sets in Y can be ordered in any way that is convenient to you. |
Do we need to check for valid input?
|
If this question means `do we need to return a special value if input is incorrect' then the answer is no. A simple No reply from Prolog will do. But make sure that your predicates always return from their calculations |
(Q2) Do we need to deal with calls to quicksort such as quicksort(U,[1,2,3,4])?
| No |
Hint: In Q5, why do we need to have A and B appear in the input to the predicate table?
|
Obviously we do not need A and B in order to read their values inside the predicate - since we are going to consider all possible values for them anyway. The point to having them in the argument list, along with Expr, is to get a handle on the values of A and B as they appear inside Expr |
(Q3) is is true that in the knapsack relation we don't need to worry about the ordering of the elements in the sets?
|
No. You do have to worry about it, in the sense that both knapsack([2,3,5,6],12,[2,3,6]) and knapsack([2,3,5,6],12,[2,6,3]). should be accepted. You can however assume that in powerset, the ordering inside subsets is the same as in the original set. That is, you can accept only powerset([1,2],[[],[1],[2],[1,2]]) and say No to powerset([1,2],[[],[1],[2],[2,1]]). |

