Unformatted text preview: than O ( 1 ) time for copying. In addition, we want to keep the table size small enough, avoiding a very large table to keep only few items. One way to manage a dynamic table is by the following rules: (a) Double the size of the table if an item is inserted into a full table (b) Halve the table size if a deletion causes the table to become less than 1 / 4 full Show that, in such a dynamic table we only need O ( 1 ) amortized time, per operation. 3. Consider a stack data structure with the following operations: • PUSH( x ): adds the element x to the top of the stack • POP: removes and returns the element that is currently on top of the stack (if the stack is non-empty) • SEARCH( x ): repeatedly removes the element on top of the stack until x is found or the stack becomes empty What is the amortized cost of an operation? 1...
View Full Document
- Fall '08
- Algorithms, Array data structure