Question: Need help writing this class for my artificial intelligence class! We have a good view of BFS and DFS. Now it's the time to use
We have a good view of BFS and DFS. Now it's the time to use them to solve some problems! Write a Java program which implements Breadth-First Search and Depth-First Search algorithms to find a solution for the Water Jugs Problem (Lecture5 slides 7 and 8). As shown in the slides, the start state is (0, 0); goal states are (2, ") (either state (2, 0) or state (2, 3)). To keep things simple, a Node class is provided for you. (You can find the file Node.java on Blackboard). In this class, the method expand () generates all possible successors of one node and returns the list of all successors. You need to write a new class named WaterJugs to implement and test your algorithms. Requirements: 1) Create a method BFS that applies the Breadth-Frist search. 2) Create a method DFS that applies the Depth-First search. 3) Output the path from the start state to the goal state. 4) Your program should be able to avoid repeated states in order to find the goal state. 5) Add a counter to your methods that keeps track of how many nodes were created during a computation, as a measure of the algorithm's efficiency. Let the program output that number. Your program should be well-documented. Variable names and function names should be self-descriptive. Major functions should be explained clearly in comments 6) 7) Test your program. Make sure your program compiles and runs correctly
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
