(5 points) Suppose that we run a greedy search algorithm with h(n)=-g(n). What sort of search will the greedy search emulate?
(5 points) Come up with heuristics for the following problems. Explain whether they are admissible, and whether the state spaces contain local maxima with your heuristic: (a) path planning in the plane with rectangular obstacles, (b) maze problems, as defined in Chapter 3.
(10 points) Sometimes there is no good evaluation function for a problem, but there is a good comparison method: a way to tell if one node is better than another, without assigning numerical values to either. Show that this is enough to do best-first search. What properties of best-first search do we give up if we only have a comparison method?
(10 points) Prove that if the heuristic function h obeys the triangle inequality, then the f-cost along any path in the search tree is nondecreasing. (The triangle inequality says that the sum of the costs from A to B and B to C must not be less than the cost from A to C directly).
There's a simple game you can play with silver dollars. (A silver dollar is a coin worth $1.) There are five (5) silver dollars on the table and you and your opponent take turns picking up 1, 2, or 3 coins until none is left. You get to keep each silver dollar you pick up. But, if you pick up the last coin, you have to pay $2 to your opponent. The objective of the game is to finish with the most money.
Note that the solution to the second to last problem is wrong in the above solution writeup. You should take 3 dollars finally earning 2 dollars.
(define (RotateLeft L)
(cond ((null? L) #f)
(else (append (cdr L) (list (car L))))))
(define (RotateRight L)
(cond ((null? L) #f)
(else (append (list-tail L (- (length L) 1)) (list-head L (-
(length L) 1))))))
(define (RotateRight L)
(cond ((null? L) L)
(else
(append (list (car (reverse L)))
(reverse (cdr (reverse L)))))))
(define (Rotate L N)
(cond ((null? L) #f)
((= N 0) L)
((> N 0) (Rotate (RotateRight1 L) (- N 1)))
((< N 0) (Rotate (RotateLeft1 L) (+ N 1)))
)
)
---------------------------------------------------------------------------
(define leaf?
(lambda (obj)
(and (not (null? obj))
(not (pair? obj)))))
(define (countCellsRecursive L)
(cond ((null? L) 1) ;if at a null, it means we're hit a ")",
so + 1
((leaf? L) 1) ;+1 for every atom
(else (+ (countCellsRecursive (car L)) (countCellsRecursive (cdr L))))))
(define (countCells L) ;a dummy procedure used to subtract 1 from the
(- (countCellsRecursive L) 1)) ;result of countCellsRecursive. We subtract 1
;to account for the ")" at the end of the
;outermost "()"
---------------------------------------------------------------------------
(define (BinarySearch Tree Goal)
(cond ((null? Tree) #f) ;empty tree (have reached a null leaf)
((null? Goal) #f) ;null goal
((= Goal (car Tree)) Goal) ;found node
((< Goal (car Tree)) (BinarySearch (car (car (cdr Tree))) Goal))
((> Goal (car Tree)) (BinarySearch (car (cdr (car (cdr Tree)))) Goal))))
;The tree representation I'm using is as follows:
;-All subtrees are a list unto themselves
;-The value stored at a particular node is the first value in the list of that t
ree
;-If a node does not have a left and/or right child, a null entry is stored ther
e.
;An Example
;(6 ((3 (() (5 (() ())))) (8 ((7 (() ())) (10 (() ()))))))
;
; _____6_____
; __3__ __8__
; () _5_ _7_ _10_
; () () () () () ()