CSE 373 Winter 2003

Assignment #4 Due February 14

You are strongly encouraged to look at this assignment before the midterm, in particular the very short exercises 1 and 3.

1. (8 points) Weiss Problem 5.1

2. ( 12 points)

In this problem you will design algorithms to handle insertion, deletion, and find for open addressing hashing (aka closed hashing) using linear probing.

Assume that we want to insert non-negative integers in a table of size M using the hashing function hash (hash(i) returns an integer between 0 and M-1; you don't have to write the hash function). Initially the table is empty and all entries are set to -2. When an entry has been inserted and then deleted, the entry becomes -1.

Give pseudocode algorithms for the following 3 functions

You are not asked to implement a Rehash function.

3. (6 points) Weiss Problem 6.8

4. (10 points)

A 3-heap is like a binary heap except that each node has 3 children instead of 2 (cf. Figure 6.19; Of course one of the nodes at the next to last level might have only 1 or 2 children).

Assuming a 3-heap is stored in an array indexed 1 to Max, give formulas for computing the index of the 3 children of the node at index i. Give a formula for computing the index of the parent of a node at index i.

Using pseudocode, design:



This document was generated by Jean-Loup Baer on February, 6 2003 using texi2html