- 3

a. Design an algorithm to solve the problem. b. Analyze the algorithm.

Ferrying soldiers A detachment of n soldiers must cross a wide and deep river with no bridge in sight. They notice two 12-year-old boys playing in a rowboat by the shore. The boat is so tiny, however, that it can only hold two boys or one soldier. How can the soldiers get across the river and leave the boys in joint possession of the boat? How many times does the boat pass from shore to shore?

23rd May 2017, 6:55 PM
Elyas Albalushi
Elyas Albalushi - avatar
2 Respuestas
+ 5
This just seems more like a logic problem.. Based on a homework assignment.
23rd May 2017, 7:22 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
The algorithm is: 1. Drop one of the boy on the other side of the shore 2. Let the other boy bring back the boat 3. Remove the boy and place a soldier to reach the other side. 4. Let the small boy bring back the boat. Repeat the process for every soldier
23rd May 2017, 7:02 PM
Maaz
Maaz - avatar