Suppose that you have several numbered billiard balls on a pool table. At each step you remove a billiard ball from the table. If the ball removed is numbered n, you replace it with n balls whose number is n / 2, where the division is truncated to an integer. For example, if you remove the 5 ball, you replace it with five 2 balls. Write a program that simulates this process. Use a bag of positive integers to represent the balls on the pool table. Using Big Oh notation, predict the time requirement for this algorithm when the initial bag contains only the value n. Then time the actual execution of the program for various values of n and plot its performance as a function of n.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here