Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I'm stuck on this question 1,7, can you help me to solve this question with code in Python by using GRAPH search instead of

Hello, I'm stuck on this question 1,7, can you help me to solve this question with code in Python by using GRAPH search instead of TREE search ? PLEASE run the test cases first before posting it. Ignore the following task 1,1 and so on. The procedure is same as 1.6. Thank you so much

image text in transcribedimage text in transcribed

Implement the function mnc_tree_search with Tree Search using your proposed representation described in Tasks 1.1, 1.2 and 1.3. mnc_tree_search takes two integers m and c, which are the numbers of missionaries and cannibals on one side of the river initially, and returns the solution to the problem as a tuple of steps. Each step is a tuple of two numbers m and c, indicating the number of missionaries and cannibals on the boat respectively as the boat moves from one side of the river to another. The odd steps are for the boat moving from right to left and the even steps are for the boat moving from left to night. Note that 1= no. of cannibals) - Step 3: 1 cannibal and 1 missionary row the boat to the RHS of the river - End: 2 missionaries and 1 cannibal are on the RHS of the river Task 1.7 - Implement Graph Search Next, implement the function mnc graph_search with Graph Search using your proposed representation described in 1.1, 1.2 and 1.3. mnc_graph_search takes two integers m and c, which are the numbers of missionaries and cannibals on one side of the river initially, and returns the to the problem as a tuple of steps following the format in Task 1.5. def mnc_graph_search (m,c) : Graph search requires to deal with the redundant path: cycle or loopy path. Modify the above implemented tree search algorithm to accelerate your AI. Parameters m : no. of missionaries c: no. of cannibals Returns Returns the solution to the problem as a tuple of steps. Each step is a tuple of two numbers x and y, indicating the number of missionaries and cannibals on the boat respectively as the boat moves from one side of the river to another. If there is no solution, return False. \# TODO: add your solution here and remove "raise NotImplementedError" raise NotImplementedError \( \begin{array}{ll}\text { \# Test cases } \\ \text { print(mnc_graph_search }(2,1)) & \#((2, \theta),(1, \theta),(1,1)) \\ \text { print(mnc_graph_search }(2,2)) & \#((1,1),(1, \theta),(2, \theta),(1, \theta),(1,1)) \\ \text { print(mnc_graph_search }(3,3)) & \#((1,1),(1, \theta),(\theta, 2),(\theta, 1),(2, \theta),(1,1),(2, \theta),(\theta, 1),(0,2),(1,0),(1,1)) \\ \text { print(mnc_graph_search }(4,4)) & \# \text { False }\end{array} \)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions