Question: Consider a modified version of the 8-puzzle problem in which adjacent tiles that differ by one in value can be exchanged in addition to the

Consider a modified version of the 8-puzzle problem in which adjacent tiles that differ by one in value can be exchanged in addition to the allowed blank moves in the 4 directions: up, left, write and down

some one help me to write a code using breadth first search algorithm

this is the algorithm :

Breadth First search Algorithm

Repeated states are not allowed

1. create a list of nodes called OPEN containing one node representing the initial state of the problem.

2. create an empty list of nodes called CLOSED.

3. while (OPEN is not empty) do {

3.1. N=first node in OPEN.

3.2 Delete N from OPEN.

3.3 add N to CLOSED.

3.4 if N contains a goal state return N and the solution.

3.5. E= expand(N). // E is the set of states that result from applying the operators to the state inside N

3.6 for every state i in E do

if (i is not neither in any OPEN node nor in any CLOSED node)

Create a node for i and add it at the end of OPEN;

// i should point to N which is on the CLOSED list

}//while

4. return failure.

Consider a modified version of the 8-puzzle problem in which adjacent tiles

Write the program in either C++ or Java. The program when executed must ask the user to enter the text file name containing the initial state and goal state of the problem. Assume that the input file is always formatted as (just an example) using breadth first search algorithm. Assume no repeated states in the search tree N 4 5 3 1 6 initial state 00 7 1 2 3 4 5 6 goal state 7 8 The program should output for each of the two algorithms: 1. The solution expressed as sequence of operations. 2. Number of states expanded

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!