Question: in java language Problem description: A group of K persons (K > 1) want to cross a bridge from East to West during the night.




in java language
Problem description: A group of K persons (K > 1) want to cross a bridge from East to West during the night. The persons that are crossing the bridge must use a flashlight. There is only one flashlight. The bridge is very narrow and allows two persons maximum to cross it at the same time. Two persons go from east to west and one person returns with the flashlight from west to east. If the two persons are crossing the bridge together, they are crossing it at the speed of the slower one. These people are trying to cross the bridge as quickly as possible. Use 3 search strategies (UCS, IDS and A*) to find the best order for these persons to cross the bridge in a the minimum time. Input file: a. K, number of people b. A list of K numbers, showing the time required by each person to pass the other side. Output: Your program should printout the following information for each search strategy: 1) Sequence of trips taken by the group along with direction of each trip for each strategy (solution) 2) Total time required to have all K people crossing using each strategy (solution cost) 3) Total number of generated nodes (Search time) for each strategy 4) Maximum number of nodes concurrently stored in the system (Space requirement) for each strategy. Implementation: Input file: 3 5 5 4 7 The first line represents the number of persons. There are three people, K=3. The first person needs 5 (time units) to pass from one side to the other. The second person needs 4 (time units). The first person needs 7 (time units). The time values are separated by whitespace characters (tabs and/or spaces). Output: The solution of the the problem described in the input file is as follows: first the person that needs 5 time units goes with the person that needs 4 time units to the west side (displayed below as 5,4). Then the person that needs 4 time units returns with the flashlight to the east side displayed below as 4). Finally, the person that needs 4 time units goes with the person that needs 7 time units to the west side displayed below as 4,7). Output: The solution of the the problem described in the input file is as follows: first the person that needs 5 time units goes with the person that needs 4 time units to the west side (displayed below as 5,4). Then the person that needs 4 time units returns with the flashlight to the east side (displayed below as 4). Finally, the person that needs 4 time units goes with the person that needs 7 time units to the west side (displayed below as 4,7). UCS Displayed solution 5,4 4 4,7 Solution Cost 16 Search Cost Display the number of nodes generated Space Requirement Display the number of nodes kept in memory. Interfaces: You will need to implement the following interface: import java.util.*; public interface Solver { ArrayList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
