You are on page 1of 12

Luger book

Question: no: 1: A Hamiltonian path is a path that uses every node of the graph exactly once .what conditions are necessary for such a path to exit? Is there such a path in the Konigsberg map? Solution:In proving the walk was impossible, Euler focused on the degree of the nodes of graph, observing that a node could be of either even or odd degree. An even degree node has an even number of arcs. With the exception of its beginning and ending nodes, the desired walk could have to leave each node exactly as often as it entered it. Nodes of odd degree could be used only as the beginning or ending of the walk, because such nodes could be crossed only a certain number of times before they proved to be a dead end. The traveler could not exit the node without using a previously traveled arc. Euler noted that unless a graph contained either exactly zero or two nodes of odd degree, the walk was impossible. If there were no nodes of odd-degree nodes, the walk could begin and end at the same node. The walk is not possible for graphs containing any other number of nodes of odd degree, as is the case with the city of Konigsberg. This problem is now called finding an Euler path through a graph. Depth first and breath first search are two strategies for searching a state space. We compare these and make the added distribution between goal-driven and data driven search. use a graph theory to analyze the complexity of a variety of problems .

Question: no: 2: Give the graph representation for the farmer, wolf, goat, and cabbage problem of section 14.3(see figure 14.1 and 14.2) /let the nodes represent states of the world; e.g., the farmer and the goat are one the west bank and the wolf and cabbage on the east. Discuss the advantages of breath first and depth first for searching this space? Solution:A farmer with his wolf, goat, and cabbage come to the edge of a river they wish to cross. There is a boat at the river's edge, but, of course, only the farmer can row. The boat also can carry only two things (including the rower) at a time. If the wolf is ever left alone with the goat, the wolf will eat the goat; similarly, if the goat is left alone with the cabbage, the goat will eat the cabbage. Devise a sequence of crossings of the river so that all four characters arrive safely on the other side of the river. Depth first and breadth first search both have some advantages. Which is best depends on properties of the problem you are solving. For tree search at least, depth first search tends to require less memory, as you only need to record nodes on the `current' path. If there are lots of solutions, but all at a comparable `depth' in the tree, then you may hit on a solution

having only explored a very small part of the tree. On the other hand, that may not be the best solution. Also, depth first search may get stuck exploring long (and potentially infinite) blind alleys, when there is in fact a solution path of only one or two steps. (We could prevent this by setting a depth limit to our search, but then it wouldn't be exhaustive.). So depth first is good when there are many possible solutions, and you only want one (and you don't care which one). It may be less appropriate when there is only one solution, or if you want the shortest one. Breadth first search may use more memory, but will not get stuck in blind alleys, and will always find the shortest path first (or at least, the path that involves the least number of steps). It may be more appropriate when exploring very large search spaces where there is an expected solution which takes a relatively small number of steps, or when you are interested in all the solutions (perhaps up to some depth limit). Example 3.4: The problem may be stated as follows. A farmer wants to transfer his three belongings, a wolf, a goat and a cabbage, by a boat from the left bank of a river to its right bank. The boat can carry at most two items including the farmer. If unattended, the wolf may eat up the goat and the goat may eat up the cabbage. How should the farmer plan to transfer the items? Answer: The illegal states in the problem are (W,G | | F,C) , (G,C | | F,W), (F, W | | G, C) and ( F, C | | W, G) where F, G, | |, W and C denote the farmer, the goat, the river, the wolf and the cabbage respectively. In the first case the wolf and the goat are at the left bank, and the farmer and the cabbage are at the right bank of the river. The second case demonstrates the presence of goat and cabbage in the left and the farmer and the wolf in the right bank. Similarly, the other illegal states can be explained easily. A part of the knowledge base for the system is given below. PR 1: (F, G, W, C | | Nil ) -> ( W, C | | F, G) PR 2: (W, C | | F, G) -> ( F, W, C | | G) PR 3: (F, W, C | | G) -> (C | | F, W, G) PR 4: (C | | F, W, G) -> ( F, G, C | | W) PR5: (F, G, C | | W) -> (G | | F, W, C) PR 6: ( G | | F, W, C) -> ( F, G | | W, C) PR 7: ( F, G, | | W, C) -> ( Nil | | F,G, W, C) PR 8 ( F, W, C | | G) -> ( W | | F, G, C) PR 9: ( W | | F, G, C) -> ( F, G, W | | C) PR 10: ( F, G, W | | C) -> ( G | | F, W, C) PR 11: ( G | | F, W, C) -> ( F, G | | W,C) PR 12: ( F, G | | W, C) -> ( Nil | | F, G, W, C) Forward Reasoning: Given the starting state ( F, G, W, C | | Nil) and the goal state (Nil | | F, G, W, C), one may expand the state-space, starting with (F,G,W,C | | Nil) by the supplied knowledge base, as follows

Backward Reasoning: The backward reasoning scheme can also be invoked for the problem. The reasoning starts with the goal and identifies a

Question: no: 4: Hand run the backtrack algorithm on the graph in figure 3.27 . Begin from state A keep track of the successive of the successive values of NSL,SL,CS,etc Solution:-

We Initialize: SL = [A], NSL = [A], DE= [ ], CS = [A]


AFTER ITERATION 0 1 2 3 4 5 6 7 8 9 10 11 12 13 CS [A] [B] [E] [J] [K] [L] [F] [G] [M] [N] [H] [O] [P] [C] SL [A] [B,A] [E,B,A] [J,E,B,A] [k,E,B,A] [L,E,B,A] [F,B,A] [G,B,A] [M,G,B,A] [N,G,B,A] [H,G,B,A] [O,H,G,B,A] [P,H,G,B,A] [C,A] NSL [A] [B,C,D,A] [E,F,G,B,C,D,A] [J,K,L,E,F,G,B,C,D,A] [K,L,E,F,G,B,C,D,A] [L,E,F,G,B,C,D,A] [F,G,B,C,D,A] [G,B,C,D,A] [M,N,H,G,B,C,D,A] [N,H,G,B,C,D,A] [H,G,B,C,D,A] [O,P,H,G,B,C,D,A] [P,H,G,B,C,D,A] [C,D,A] DE [] [] [] [] [J] [K,J] [E,LK,J] [F,E,LK,J] [F,E,LK,J] [M,F,E,LK,J] [N,M,F,E,LK,J] [N,M,F,E,LK,J] [B,G,H,P,O,N,M,F,E,LK,J] [B,G,H,P,O,N,M,F,E,LK,J]

14 15 16 17

[D] [I] [R] []

[D,A] [I,D,,A] [R,I,D,A] []

[D,A] [I,D,A] [R,I,D,A] []

[C,B,G,H,P,O,N,M,F,E,LK,J] [C,B,G,H,P,O,N,M,F,E,LK,J] [C,B,G,H,P,O,N,M,F,E,LK,J] [A,D,I,R,C,B,G,H,P,O,N,M,F,E,LK,J] [A D I R C G H P O N M F E L K J]

The algorithm returns FAIL. Question: no: 6: Determine whether goal-driven or data driven search would be preferable for solving each of the following problems. Justify your answer. a. Diagnosing mechanical problems in an automobile. Solution:Usually a goal-driven. Justification:The search can be where the data is collected, suggesting possible goals (causes of the symptoms). Then each goal is checked. b. You have met a person who claims to be your distant cousin, with a common ancestor named John Doe; you would like to verify her claim. Solution:Data driven search Justification:Data driven search uses the knowledge and constraints found in the given data of a problem to guide search along lines known to be true.

c. Another person claim to be your distant cousin .he does not know the common ancestor named but knows that it was no more than eight generations back. You would like to either find this ancestor or determine that she did not exit. Solution:To find there existence we use goal driven search. Justification:It is difficult to form a goal or hypothesis .there may be different ways to find out the path or exact existence. Thats why this is goal driven search. But may be data-drive, because there are very few goals to investigate. d. A theorem prover for plane geometry. Solution:Goal-driven search possible. Justification:-

Theorem provers are almost universally goal-driven. The alternative of developing all possible theorems that follow from the axioms of geometry hoping to find the theorem in question is both theoretically and computationally impossible for any interesting proof. e. A program for examining sonar readings and interpreting them , such as telling a large submarine from a small submarine from a whale from a school of fish. Solution:- Data-driven, Justification:This type of problem is almost always data-driven, unless there are very few goals to investigate f. An expert system that will help a human classify plants by species, genus, etc. Solution:Usually data-driven. Justification: There are too many possible goals in most interesting cases. Question: no:7: Choose and justify a choice of breath or-depth first search for examples of Exercise6 Solution:a . Disgnosing mechanical problems in an automobile . Solution:Usually done depth-first. Justification:This allows the program to follow a reasoning goal or hypothesis when a previous one is confirmed or denied. b .You have met a person who claims to be your distant cousin,with a common ancestor named john Doe ,you would like to verify her claim. Solution:Usually done depth first search Justification:Depth first search uses the knowledge and constraints found in the given search of a problem to guide search along lines known to be true. c. Another person claim to be your distant cousin .he does not know the common ancestor named but knows that it was no more than eight generations back . You Would like to either find this ancestor or determine that she did not exit. Solution:Usually done depth-first. Justification:-

This allows the program to follow a line of reasoning and only change to a new goal or hypothesis when a previous one is confirmed or denied. d .A theorem prover for plane geometry. Solution:Theorem provers are almost universally breath first search. Justification:The alternative of developing all possible theorems that follow from the axioms of geometry hoping to find the theorem in question is both theoretically and computationally impossible for any interesting proof. e. A program for examining sonar readings and interpreting them , such as telling a large submarine from a small submarine from a whale from a school of fish. Solution:This type of problem is almost depth first search. Justification:This type of problem is almost always depth-first search, unless there are very few goals to investigate f. An expert system that will help a human classify plants by species,genus,etc. Solution:Use of depth first search Justification:Usually depth-first, as was the Unify algorithm. This allows unification substitutions to be pushed forward through the remaining expression.

Question: no: 9: Trace the goal driven good-dog problem of example 3.34 in a data driven fashion. Solution:Location(X,Z) Gooddog(X) Collie(X) Collie(fred) trained(X) trained(fred) master(X,Y) master (fred,sam) location(Y,Z) day(Saturday) -(warm(Saturday))

Subsituition={fred/X,sam/Y,musesum}

Question: no: 11: Trace a data driven execution of the financial advisor of example 3.35 for the case of an individual with four dependents, $18,000 in bank, and a steady income of $25,000 per year. Based on a comparison of the problem and example in the text, suggest a generally best strategy for this problem. Solution:-

\Investment(x) Investment(savings) Savings_account(inadequate) Amount_saved(x) dependents(Y) dependents() -greater(X,minsavings(Y)) Fail savings_account(adequate) amount_saved(X) dependents(Y) greater(X,minsavings(Y)) Investment(stocks)

Amount_savined(18000)

Amount_savined(25,000)

dependents() Income(adequate)

Earings(X,steady) Earings(25,000,steady)

dependents(Y) dependents(2)

greater(X,minsavings(Y))

The highlighted portion is the best strategy to solve this problem. Question: no: 12: Add rules for adjectives and adverbs to the English grammar of Example 3.36. Solution:Adjective A word that describes or modifies a noun. Answers the questions "how many," "what kind," etc. ex: happy, suicidal, red, and dangerous. Adverb A word that describes or modifies a verb. ex: carefully, quickly, wisely. also sometimes modifies an adjective. ("She was very tall." 'very' is an adverb modifying 'tall,' which in turn an adjective is modifying 'she'.) Adverbs usually, but not always, end in "-ly". (However, not every word ending in "ly" is an adverb: "friendly," for example, is an adjective An adjective is a word joined to a noun or other substantive word or expression, to describe it or to limit its application. Adjectives are divided into four classes:(1) Descriptive adjectives, which describe by expressing qualities or attributes of a substantive. (2) Adjectives of quantity, used to tell how many things are spoken of, or how much of a thing. (3) Demonstrative adjectives, pointing out particular things. (4) Pronominal adjectives, words primarily pronouns, but used adjectively sometimes in modifying nouns instead of standing for them. they include relative and interrogative words. s np and vp. np art and noun. vp verb. subject.noun adjective is modification of noun nounAdjective adverb is modification of adjective Verb adverb Question: no: 14:

Add grammar rules to the English grammar of example 3.36 that allow comlex sentences such as , Sentence.sentence and sentence Solution:Sentence.subject and hverb and verb and object. s np and vp. np art and noun. vp verb. Subject.noun and pronoun noun.name of every thing noun [cat]. noun [dog]. art [the]. art [a]. verb [jumps]. verb [sings]. verb [likes]. pronoun I or we or you or they or she or he or her or his or him or yours or us or me or them . hverbis or am or are or was or were or has or have or had or will or shall . object Subject or noun and pronoun

Question: no: 13: Add rules for (multiple) prepositional phrases to the English grammar of Example 3.3.6. Solution:-

You might also like