hw5 - CS 473 Homework 5(due March 9 2010 Spring 2010 1 A...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 473 Homework 5 (due March 9, 2010) Spring 2010 1. A multistack consists of an infinite series of stacks S 0 , S 1 , S 2 ,..., where the i th stack S i can hold up to 3 i elements. The user always pushes and pops elements from the smallest stack S 0 . However, before any element can be pushed onto any full stack S i , we first pop all the elements off S i and push them onto stack S i + 1 to make room. (Thus, if S i + 1 is already full, we first recursively move all its members to S i + 2 .) Similarly, before any element can be popped from any empty stack S i , we first pop 3 i elements from S i + 1 and push them onto S i to make room. (Thus, if S i + 1 is already empty, we first recursively fill it by popping elements from S i + 2 .) Moving a single element from one stack to another takes O ( 1 ) time. Here is pseudocode for the multistack operations MSP USH and MSP OP . The internal stacks are managed with the subroutines P USH and P OP . MP
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 3

hw5 - CS 473 Homework 5(due March 9 2010 Spring 2010 1 A...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online