Limited access

Upgrade to access all content for this subject

Alex has written code implementing a prey-predator relationship. He has coded a class for the sharks (predator), the fish (prey), and a graphical view to show these creatures on a grid moving about in an ocean of blue. Though the code appears to work correctly, Alex finds that the implementation is terribly slow.

If he has more than 25 or so creatures in his ocean, the computer slows to a crawl and it takes hours to run his simulation. He would like to have the simulation running with thousands of creatures in the ocean.

What you recommend to Alex to improve the implementation of his simulation?

Select TWO answers.


Consider implementing his code in a different language — some languages are better suited to running simulations with a large number of objects than others.


Consider choosing a different problem — the ocean is too big a place to create a simulation on a modern computer.


Consider his graphical implementation — perhaps there is a way to speed up the graphs he has paired with simulation.


Consider adding a plankton class for the fish to consume — perhaps adding a layer of complexity will give insight into the fish-shark relationship.

Select an assignment template