CPSC 327 | Data Structures and Algorithms | Spring 2024 |
For the following problem, develop an iterative algorithm to solve the problem using the 15 step iterative algorithm development template. Give each of the steps; don't just give an algorithm — the point here is understanding the process and being able to apply it.
You are in the middle of a lake of radius 1. You can swim at a speed of 1 and can run infinitely fast. There is a smart monster on the shore who can't go in the water but can run at a speed of 4. Your goal is to swim to shore, arriving at a spot where the monster is not, and then run away. How do you do this?
This is a different style of problem, as the goal is just to figure out the swimming strategy rather than to write a program to carry out the swimming strategy. However, the iterative algorithm development process (with the exception of the "determining efficiency" steps) is still applicable --- think of the swimming strategy as a series of simple instructions about which way to swim for the next interval of time, and the goal is to produce that list of instructions.