MIDTERM EXAM FOR YEAR 2005.



Each person has a different problem to solve. One problem for person is required. You have to return the work in one week. Your report should include source code of LISP program with comments, exhaustive tests to prove that program is correct and explanation in a separate page. Tests of auxiliary LISP functions are also required, you can use TRACE or TRACESET functions to document your software well.
You can reuse somebodys else program from WWW, but you have to give full credits.

LISP PROBLEMS.


  1. Problem 1. Creation of binary decision tree for dialog.
    We discussed this problem in the class and on Fridays.
    Given is a table with answers as columns and key-words as rows. This table associates the key-word and the respective answer by value "1" in the table, otherwise the value is "0". If the word X, corresponding to the column F appears in the input list, it is represented by a 1 on their intersection. You have to write a program to create the best decision tree for the game of "20 questions". This should be a conversation with a robot about issues such as weather, places, people, etc. The decision table is binary only and is prepared by the human in advance. Based on the decision table the program automatically creates the decision tree and next uses it in the conversation based on Eliza-like search of keywords in the text from a human. (use only the LISP MEMBER function to see if the word exists in the sentence). The questions from the human are asked step by step and the robot evaluates the decision tree accordingly. The answers are only "yes" and "no". Finally the robot responds with the sentence stored as a column. Write two versions. In one the human asks, in the second the robot asks.

  2. Problem 2. Creation of multiple-valued decision tree for dialog.
    We discussed this problem in the class and on Fridays.
    This problem is similar to the previous one. The features are now multiple-valued and correspond to values of variables such as "color of nose", "size of eyes", etc. The decision table represents people who are being recognized by the camera. Do not write the software for preprocessing. The ready table is prepared by a human and given as a data to your program!!
    Your program, a generalization of the one from Problem 1, should make decisions who is the person we are talking about, is this John or Mary, etc. The columns correspond to people, the rows to the features and their values. So, you ask if this person has a long nose, red eyes, wears glasses, etc. And finally the decision is made who is the person.
    Your software should illustrate two stages: (1) creation of the tree, as explained above; (2) evaluation of the tree, it means the use of the tree to make a decision who is the person.

  3. Problem 3. Classification based on multiple-valued decision table.
    We discussed this problem in the class and on Fridays.
    The decision table is given with multiple-valued variables (attributes) as in the previous problem. The features are multiple-valued and correspond to values of variables such as "color of nose", "size of eyes", etc.y The decision table represents people who are being recognized by the camera. This table is done by a human and given as a data to your program.
    For each person, there is also an ADDITIONAL information if this person is beautiful or not. Use the decision tree to learn the beautiful people. Apply to people from the table. Apply to new people that are not in the table. Again, you have to write the program to create the decision tree and the program to evaluate it.

  4. Problem 4. The puzzle of Missionaires and Cannibales.
    We discussed this problem on Friday.
    Solve the problem of cannibales and missionaires, which was illustrated for three Cannibales and three Missionaires and a boat with 3 people. Now the number of missionaires and cannibales is arbitrary (but there is always the same numbers of them) and the number of people in the boat is arbitrary. Create a table with results for n = the number of cannibales = the number of missionaires, k = the number of people in the boat. Assume that everybody can be a sailor of the boat (can row) and the boat needs at least one sailor. Use any search method.

  5. Problem 5. The puzzle of Towers of Hanoi.
    Write a program to solve the puzzle of Towers of Hanoi with n towers and the shortest time to solve the problem that is possible. Demonstrate it for n=3 , n=4 and n=5 towers and 8 tiles. Please note that the solution for n=3 is in several books, but if you have more towers than 3, using directly this solution would lead to very non-efficient results.

  6. Problem 6. SAT solver.
    We discussed this problem in classes.
    Given is a CNF (Product of Sums of literals) formula in binary logic. Find the product of literals that satisfies this formula, i.e. write a SAT solver program. Use recursion or stack-based search.

  7. Problem 7. Boolean Simplifier.
    We discussed this problem in classes.
    Write a recursive Lisp program to simplify Boolean expression represented as Lisp lists in prefix notation. Do not write all rules, do not try to get optimal solution. Just explain the principle of simplifying circuit recursively from inputs to outputs and outputs to inputs. Especially consider all "propagation of constants" rules such as (AND X 0) ==> 0 or (OR 1 Y) ==> 1.

  8. Problem 8. Combinatorial Generator.
    Write a short recursive or stack-based Lisp program to generate all combinations of n out of k words from a list without repeatitions of words but with all permutations. Write its variant were there are no permutations.
    For instance, if the list of words is {A, B, C, D} with k = 4 and you are asked to have n=2 you will generate AB, BA, AC, CA, AD, BC, BD,... The order of generation of these words is arbitrary. This must be an exhaustive search, not a random number generator based one.

  9. Problem 9. Combinatorial Generator with repeatitions.
    Write a short recursive or stack-based Lisp program to generate all combinations of n out of k words from a list with all repeatitions of words and with all permutations.
    For instance, if the list of words is {A, B, C, D} with k = 4 and you are asked to have n=2 you will generate AA, AB, BA, BB, AC, CC, CA, AD, BC, BD,... The order of generation of these words is arbitrary. This must be an exhaustive search, not a random number generator based one.

  10. Problem 10. Depth-First Graph Searching.
    Given is a graph represented by a coincidence matrix with distances. It is represented as a LISP array. Write a depth-first program, called like SEARCH (A D) for nodes A and D, to search the shortest path between any two of its nodes given as the input data. Print the path as a sequence of nodes and the distances reached in each node. If there are many such paths, print each of them.

  11. Problem 11. Breadth-First Graph Searching.
    Given is a graph represented by a coincidence matrix with distances. It is represented as a LISP list, for instance ( (A B 3) (A C 4) (B D 7) (A D 7) ...). Write a breadth-first program, which is called such as BREADTH (A D) for nodes A and D, to search the shortest path between any two of its nodes given as the input data. Print the path as a sequence of nodes and the distances reached in each node. If there are many such paths, print each of them.