Due Wednesday, April 21 2004 at start of class. (Place stabled assignment with name, id number, section number, lab number, etc on top of desk at front of class.) |
This homework is due on Wednesday, April 21 2004 at the start of the class. (Place your stapled assignment with your name, id number, section number, lab number, etc, on top of my desk at the front of the class.) |
twice as large). grow() takes time proportional to the current table_size. |
twice as large). The operation grow() takes time proportional to the current table_size. |
of half the size. This saves memory. |
of half the size. This saves memory. The operation |
there is a sequence of N push() and pop() operations that takes time proportional to N2. |
there is a sequence of N push() and pop() operations that takes total time proportional to N2. |
operations taking more than O(N) time). Hint: if a the set_size() call does resize the table, how many push() or pop() operations must have proceeded |
operations taking more than O(N) time). Hint: if a set_size() call does grow or shrink the table, how many push() or pop() operations must have preceded |
Recall the UNION-FIND data type discussed in class Friday, week 1 ([/Notes 04 02]?). |
Recall the UNION-FIND data type discussed in class on Friday, week 1 ([/Notes 04 02]?). |
In class we discussed a particular implementation of the data type (also described in Section 4.2.2 of the text), and showed that for that implementation the time taken to support N UNION or FIND operations |
In that class we discussed a particular implementation of the data type (also described in Section 4.2.2 of the text), and showed that, for that implementation, the total time taken to support N UNION or FIND operations |
Now consider the alternate implementation outlined in section 4.2.3 of the text: |
Now, consider the following alternate implementation (also outlined in section 4.2.3 of the text): |
Each set is represented as a tree containing the elements in that set, with edges directed from each element to its parent in the tree. |
Each set is represented as a tree; the nodes of the tree represent the elements in that set. The tree edges are directed from each node to its parent node in the tree. |
FIND(e) is implemented by tracing the parent pointers from the element to the root of e's tree and returning the name of the element stored at the root. |
FIND(e) is implemented by tracing the parent pointers from the node corresponding to e to the root of e's tree, and returning the name of the element stored at the root. |
set with less elements) to point to the other root (thus making one tree out of two). |
set with less elements) so that it points to the root of the other tree (thus making one tree out of two). |
3A. Show that ∑i=1n log i is O(n log n). It is enough to show that the sum is less than (c n log n) for some constant c. |
3A. Show that ∑i=1n log( i) is O(n log n). Hint: It is enough to show that the sum is less than (c n log n) for some constant c. |
3B. Show that the sum above is Ω(n log n). It is enough to show that the sum is at least (c n log n) for some constant c > 0. |
3B. Show that the sum above is Ω(n log n). Hint: It is enough to show that the sum is at least (c' n log n) for some constant c' > 0. |
Note: recall from class that ∑i=0n ci = Θ(cn) for c>1. This will not be useful for the above exercises. |