Question: Fast percolation test. Modify the recursive flow() method in PROGRAM 2.4.5 so that it returns as soon as it finds a site on the bottom

Fast percolation test. Modify the recursive flow() method in PROGRAM 2.4.5 so that it returns as soon as it finds a site on the bottom row (and fills no more sites). Hint: Use an argument done that is true if the bottom has been hit, false otherwise. Give a rough estimate of the performance improvement factor for this change when running PercolationPlot. Use values of n for which the programs run at least a few seconds but not more than a few minutes.

Note that the improvement is ineffective unless the first recursive call in flow() is for the site below the current site.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithm Design Questions!