next up previous contents
Next: Solution Up: Procedures Previous: Solution

 

Maggot/Onion Recursive Procedure Conundrum

An onion with an unknown number of layers contains a maggot at an unknown layer. Write a recursive function which will determine the depth of the maggot using the probability of 0.1 of a maggot being at a particular layer and a random number generator.

Go back to Notes gif




next up previous contents
Next: Solution Up: Procedures Previous: Solution

©University of Liverpool, 1997
Thu May 29 10:11:26 BST 1997
Not for commercial use.