Prolog Assgn
Prolog Assgn
1. Write a prolog program to represent a family tree and write the predicates for different
relationships like father, mother, brother, sister, cousin, grandmother, grandfather etc.
8. Write a prolog program to find the sum and average of a list of numbers.
9. Write a prolog program to find the minimum and maximum from a list of numbers.
11. Write a prolog program to find whether a number is a member of a list or not.
14. Write a prolog program to delete the ‘K’th element from a list.
17. Write a prolog program to determine whether an input string is accepted by the DFA
constructed from the regular expression: c(a|b)*d+
18. Write a prolog program to determine whether an input string is accepted by the DFA
constructed from the regular expression: (a|b)+(cd)*e
19. Write a prolog program to implement two-input XOR gate using two-input NAND gates only.
22. Write a prolog program to sort a given list using insertion sort.
23. Write a prolog program to reverse a list. Also determine whether a given list is palindrome or
not.
24. Write a prolog program to find the union, intersection and set difference of two lists of elements.
26. Write a prolog program to eliminate the duplicate elements of a list. The output list should
contain the unique elements.
28. Write a prolog program to generate a binary tree and write predicates for the following: path,
leaf, root, sibling, height, level.
29. Write a prolog program to generate the nodes traversed in preorder, postorder and inorder
traversals.
30. Write a prolog program to count the number of vowels in a list of characters (word).