Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
pp:l11 [2020/05/04 15:34]
pdmatei
pp:l11 [2020/05/19 14:42] (current)
pdmatei
Line 34: Line 34:
 7. Use the previous predicate to write ''​repeat/​3''​ which returns a list containing the same value ''​X''​ repeated ''​K''​ times. 7. Use the previous predicate to write ''​repeat/​3''​ which returns a list containing the same value ''​X''​ repeated ''​K''​ times.
  
-8. Write a function ​''​pal/​1''​ which generates **all** lists of palindromes. Hint: use only ''​append''​.+8. Write a predicate ​''​pal/​1''​ which generates **all** lists of palindromes. Hint: use only ''​append''​
 + 
 +9. Write a predicate ''​ksubset/​3''​ where ''​ksubset(C,​K,​V)''​ generates all sets (represented as lists) ''​C''​ with ''​K''​ elements from the list ''​V''​. Hint: build the recursion scheme after ''​K''​. 
 + 
 +10. Write a predicate ''​subset''​ where ''​subset(C,​V)''​ generates all subsets of ''​V''​. Hint: build the recursion scheme after **each** element in V. 
 + 
 +11. **What is the difference between ''?​- length(C,​K),​ subset(C,​V).''​ and ''?​- ksubset(C,​K,​V).''?​** where ''​K''​ is an instantiated variable (with a value less or equal to the size of ''​V''​). Write your answer down. 
 + 
 +12. Implement ''​kvertexcover/​3''​ where ''​kvertexcover(C,​K,​G)''​ generates all ''​K''​-coverings in ''​G''​. ''​G=[V,​E]''​ where ''​V''​ is a set of nodes and ''​E''​ is a set of undirected edges. Hint: use negation to express a //​universal//​ constraint. 
 + 
 +13. Implement ''​kclique/​3''​. 
 + 
 +14. Implement ''​connected/​4'',​ where ''​connected(X,​Y,​P,​G)''​ generates all paths ''​P''​ between nodes ''​X''​ and ''​Y''​ in graph ''​G''​. 
 + 
 +15. Implement ''​ham/​2''​ where ''​ham(P,​G)''​ generates all **hamiltonian paths** in G.