Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve it using JAVA language 1 of 3 Programming assignment #1 Due Date: 28 FEB 2021 1 Introduction The students can work in groups of

Solve it using JAVA language image text in transcribedimage text in transcribedimage text in transcribed

1 of 3 Programming assignment #1 Due Date: 28 FEB 2021 1 Introduction The students can work in groups of 2-3 students. The assignment is composed of two consecutive parts. The first part is to development a program. Whereas in the second part an oral presentation will be prepared and presented. 2 Problem description: A group of 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. 3 Implementation: Input file: 3 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). 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> solve(String fileName, Algorithm alg); } Algorithm is an enumeration defined as follows: public enum Algorithm { UCS, IDS, AStar; } The method solve(String fileName, Algorithm alg) takes as input the name of the input file and the name of the search strategy and returns the solution of the problem as an ArrayList containing an ordered sequence of sets of persons that cross the bridge at each step. Example: ArrayList l={ (5,4),(4),(4,7)} //The first set (5,4) in the list is the first set of persons to cross the bridge and the last set (4,7) in the ArrayList is the last set of persons to cross the bridge. The order of the sets in the ArrayList is important

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

Define Administration and Management

Answered: 1 week ago