I am currenlty improving my problem solving skills and i stumble upon this problem, I thought it is quite a simple problem but upon further exploring it is harder than i thought it would be. Here is what i have tried:
- I consider the table to be a tree(data structure) problem like the top to be the root node (level 0) and the nodes on table to be level 1.
- I want to add the swaping of the elements and then each time i swap the elements, I traverse the tree to check if they are in the goal order
I want to know how would you approach this problem.
Note The solution is already available here, but i don't understand it. Solution
In Squares World, there are squares and a table big enough to hold all the squares. Each
square is on the table or on a single other square. For each square a, either it is clear or it
has another unique square b that sits on it. Here we can only pick a single clear square and
i) move it from another square onto the table(Figure 1(a)), ii) move it from the table onto
another clear square(Figure 1(a)), iii) from a square onto another clear square(Figure 1(b)).
In a single move, squares are not allowed to hop over others(Figure 1(c)).
In this problem, we assume that there are only three squares with the same size (the edge
length is one), A,B and C. Our table is a line and its length is three. Of course, the squares
can only stay on the table. Your mission is to use the search methods covered in class and
start from the initial state and reach the goal state each described in (Figure 1(d)). When
expanding a node in a way results in a cycle, you can ignore that expansion.
1. Show the search tree for depth-first search. Mark the nodes with the orders they are visited. How many nodes are visited until you reach the goal?
2. Show the search tree for breadth-first search. Mark the nodes with the orders they are visited. How many nodes are visited?
3. Show the search tree for A∗ with g(s) being the number of moves so far and h(s) of your own definition. Mark the nodes with the values of f(s) = g(s) + h(s).
How many nodes are visited?
4. Which search method worked the best in this specific problem? Why?