Suppose that instead of doubling the size of an array-based stack when it becomes full, you increase the size of the array by the following sequence 3k, 5k, 7k, 9k, . . . for some positive constant k.
a. If you have an empty stack that uses an array whose initial size is k, and you perform n pushes, how many resize operations will be performed? Assume that n > k.
b. What is the average cost of the n push operations?
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here