# hw4(8) - CS 373U: Combinatorial Algorithms, Spring 2004...

This preview shows pages 1–3. Sign up to view the full content.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 373U: Combinatorial Algorithms, Spring 2004 Homework 4 Due Friday, April 2, 2004 at noon Name: Net ID: Alias: Name: Net ID: Alias: Name: Net ID: Alias: For each numbered problem, if you use more than one page, staple all those pages together. Please do not staple your entire homework together. This will allow us to more easily distribute the problems to the graders. Remember to print the name and NetID of every member of your group, as well as the assignment and problem numbers, on every page you submit. You do not need to turn in this cover page. As with previous homeworks, we strongly encourage you to begin early. # 1 2 3 4 5 6 * Total Score Grader CS 373U Homework 4 (due April 2, 2004) Spring 2004 1. Suppose we can insert or delete an element into a hash table in constant time. In order to ensure that our hash table is always big enough, without wasting a lot of memory, we will use the following global rebuilding rules: After an insertion, if the table is more than 3/4 full, we allocate a new table twice as big as our current table, insert everything into the new table, and then free the old table. After a deletion, if the table is less than 1/4 full, we allocate a new table half as big as our current table, insert everything into the new table, and then free the old table. Show that for any sequence of insertions and deletions, the amortized time per operation is still a constant. Do not use the potential method (like CLRS does); there is a much easier solution. 2. Remember the difference between stacks and queues? Good. (a) Describe how to implement a queue using two stacks and O (1) additional memory, so that the amortized time for any enqueue or dequeue operation is O (1). The only access you have to the stacks is through the standard subroutines Push and Pop ....
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.

### Page1 / 4

hw4(8) - CS 373U: Combinatorial Algorithms, Spring 2004...

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

View Full Document
Ask a homework question - tutors are online