+ Font | - Font |
"Expand nodes according to the specification of PROBLEM until we find a solution or run out of nodes to expand. The QUEUING-FN decides which nodes to look at first. [p 73]" defun general-search (problem queuing-fn) (let ((nodes (make-initial-queue problem queuing-fn)) node) (loop (if (empty-queue? nodes) (RETURN nil)) (setq node (remove-front nodes)) (if (goal-test problem (node-state node)) (RETURN node)) (funcall queuing-fn nodes (expand node problem))))) |
"Search the shallowest nodes in the search tree first. [p 74]" (defun breadth-first-search (problem) (general-search problem #'enqueue-at-end)) |
"Search the deepest nodes in the search tree first. [p 78]" (defun depth-first-search (problem) (general-search problem #'enqueue-at-front)) |
"Search depth-first, but only up to LIMIT branches deep in the tree." Push(S, Start State) Loop If S is empty, exit with failure C <-- Pop(S) If C is a goal state, exit and return C If Depth(C) < Limit for each N <-- Expand(C) Push(S, N) Goto Loop |
"Do a series of depth-limited searches, increasing depth each time. [p 79]" for depth = (0 to infinity) do result = Depth-Limited-Search(problem, depth) If result != cuttoff then return result |
Criteron | BFS | DFS | DLS | IDS |
Complete | Yes (b is finite) | NO | NO | Yes (b is finite) |
Time | O(bd+1)) | O(bm) | O(bl) | O(bd) |
Space | O(bd+1)) | O(bm) | O(bl) | O(bd) |
Optimal | Yes | NO | NO | Yes |