I am doing the unifrom cost search algorithm. I am getting my solution slightly larger than actual. The number of expanded nodes are coming larger than actual.
I used this algorithm:
Get the initial node and put it into the priority queue.The P.queue will itself arranges the nodes in it according to the cost. Lower cost node will come first.
use the while loop, it goes until the queue is empty.
remove a node from the queue and check if it is a goal state or not. if not, check if it in the visited list or not. visited list is a set that has all the nodes that are already expanded. if not present in the visited list, get its successors along with cost and action.
calculate the cost upto this node.
if the cost of succcessor is larger than the cost of parent node, add it into the queue and check if this successor is in the parentdirectory or not. If not, make him a pparent so that we can backtrack the path.
is my algorithm is right or do i need to check something else: