hw5 - Fall 11 CSci 5421Advanced Algorithms and Data...

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

View Full Document Right Arrow Icon
Fall 11: CSci 5421—Advanced Algorithms and Data Structures Out 11/21 Homework 5 Due 12/12 Please do all problems; we will grade a subset of three to four problems. Any Exercise/Problem numbers refer to the 3rd edition of the text. (Corresponding numbers for the second edition are given, where available, in parentheses.) Please follow all of the instructions given in the handout for Homework 1. 1. (12 points) Suppose that you wish to do two types of operations on an inFnite binary counter: Increment , which is as deFned in class, and Reset , which resets all bits in the counter to zero. Explain, in words, how such a counter could be implemented so that any sequence of n Increment and Reset operations on an initially-zero counter takes O ( n ) time. Use the accounting (i.e., credits- based) method. State clearly the invariant you use and the amortized cost that you assign to each operation. Hint: Consider keeping a pointer to the high-order 1-bit. 2. (12 points) Let Q be a queue, with the usual operations Enqueue and Dequeue . We wish to implement Q using two stacks S 1 and S 2 , so that the amortized cost of each queue operation is a constant. (Assume that Q is empty initially.) Describe in words how this can be done and
Background image of page 1

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

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

This note was uploaded on 01/28/2012 for the course CSCI 5421 taught by Professor Sturtivant,c during the Fall '08 term at Minnesota.

Page1 / 2

hw5 - Fall 11 CSci 5421Advanced Algorithms and Data...

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