This preview shows page 1. Sign up to view the full content.
Unformatted text preview: S i +1 to make room. But if S i +1 is already full, we ﬁrst move all its members to S i +2 , and so on. To clarify, a user can only push elements onto S . All other pushes and pops happen in order to make space to push onto S . Moving a single element from one stack to the next takes O (1) time. Figure 1. Making room for one new element in a multistack. (a) In the worst case, how long does it take to push one more element onto a multistack containing n elements? (b) Prove that the amortized cost of a push operation is O (log n ), where n is the maximum number of elements in the multistack. 3. Powerhungry function costs A sequence of n operations is performed on a data structure. The i th operation costs i if i is an exact power of 2, and 1 otherwise. Determine the amortized cost of the operation. 1...
View Full Document
This note was uploaded on 10/14/2011 for the course ECON 101 taught by Professor Smith during the Spring '11 term at West Virginia University Institute of Technology.
- Spring '11