Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help in full JAVA code for : (I already have C++, Python. I need to learn Java only) function BREADTH-FIRST-SEARCH(problem) returns a solution,

I need help in full JAVA code for : (I already have C++, Python. I need to learn Java only)

function BREADTH-FIRST-SEARCH(problem) returns a solution, or failure

node ? a node with STATE = problem.INITIAL-STATE, PATH-COST = 0 if problem.GOAL-TEST(node.STATE) then return SOLUTION(node) frontier ? a FIFO queue with node as the only element explored ? an empty set

loop do if EMPTY?(frontier) then return failure node?POP(frontier) /*choosestheshallowestnodeinfrontier */ add node.STATE to explored for each action in problem.ACTIONS(node.STATE) do

child ?CHILD-NODE(problem,node,action) if child.STATE is not in explored or frontier then

if problem.GOAL-TEST(child.STATE) then return SOLUTION(child) frontier ?INSERT(child,frontier)

Figure 3.11 Breadth-first search on a graph.

8-puzzle is a problem where you have total 9 blocks as shown in the figure below. 8-blocks/cells are marked with a number from 1 to 8 and one cell is blank/empty, the goal is to organize numbered block in clockwise in an ascending order (shown in the final state). Given an initial state and final state below I need help in finding an BFS/DFS algorithm to solve the following 8-puzzle problem. The BFS/DFS algorithm should show all intermediate states and until it reaches to the final states. The JAVA code should be executable and print all the states while executing.

image text in transcribed

283 164 7 5 Initial state (vertex) 123 8 87 4 765 Final goal state/vertex

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

Solve the system of equations. y + z = 2 2y -2y + z = 2 2 - 2

Answered: 1 week ago