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...


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.



Dec 18, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here