CS451/551 Homework 1 - due Friday March 11, 2002 ----------------------------------------------------- You must work alone on this assignment: ------------------------------------------------------------------------------ For this test, consider the following three problems: A. You begin with a number n. You continually either multiply by 2 or subtract 3 (unless that would give you a number smaller than 1). You want to find the shortest sequence (if there is one) which ends in the number 1. For example, if you start with n=5, then one possible sequence is: 5,10,7,4,1 B. Same as problem A, except that if the first number is n, then the length of the sequence must also be n. The example above from part A is OK then, because the sequence begins with 5 and has length 5, but the sequence: 5,2,4,1 is not OK, since it begins with 5 and has length 4. C. You begin with a number n. You continually either subtract 3 or subtract 5 (unless that would give you a number smaller than 1). You want to find the shortest sequence (if there is one) which ends in the number 1. For example, if you start with n=20, then one possible sequence is: 20,17,12,9,4,1 ------------------------------------------------------------------------------ Question 1: Implement these three problems like for Assignment 1. Question 2: For all three problems, give the time complexity, space complexity in the worst case, and whether it is complete or not. Don't always use the formulas blindly. Sometimes the time and space can be infinite. Sometimes the time and space can be better than you get from the forumlas, because you can sometimes give a bound on the possible states you could get. [Note: Assume that DFS never visits a node that is already on the same path, but BFS never visits a node that is already in the tree.] [Note: Don't consider optimality.] Question 3: Suppose that n=5 for problem A. Say what order the nodes will be visited in DFS, BFS and iterative deepening. [Note: When you have a choice of what node to visit next, always prefer the smaller number.] Question 4: Give a good admissible heuristic for problem C, and implement it using my A* function. You can do this just like in assignemnt 1. You implement the heuristic by defining the h-function: (defun h (state) ...) Then you can run my function by (astar start). The astar function only returns the number of nodes in the path to the goal state and the number of nodes explored. For the heuristic you defined, show on paper the tree that is constructed by the A* algorithm for n=10, and give the f-value for each node in the tree. [Note: Your operators must be redefined so that they no longer return just a list of states, but now they return a list whose elements are a pair consisting of the path cost of the edge just taken (always 1) and the state.] Question 5: Consider a two person game, which starts with a number n. You go first, and you can subtract either 3 or 5 from that number (as long as the result is a number no smaller than 1). Then your opponent subtracts either 3 or 5 from the number you get. Etc. When somebody finally gets to a number where no move is possible, then you get the value of that number (YOU get the value no matter whose turn it was). Draw the minmax tree for this game if n=16, then show which nodes are pruned with alpha beta pruning (assuming that smaller numbers are preferred when searching the tree).