CISC621 -- Fall 1999 -- HOMEWORK 4

Handed out: October 21, 1999
Due date: November 9, 1999


10. [Individual Problem] Group 5 grades this problem

Let S be a set of n integers (unordered), and let B be another integer. Give a algorithm for finding M, a maximum cardinality subset of S, such that the sum of the integers in M does not exceed B. Your algorithm should run in O(n) time assuming basic integer operations (addition, subtraction, multiplication, division, comparison) cost O(1) time.

11. [Group Problem] Group 2 grades this problem

Problem 22-2.
Remarks:
(a) A good way to show the worst case running time is to describe a specific sequence on which the running time is Theta(m^2). To be precise, you describe a family of sequences, one for each m.
(c) You may find it helpful to define a recursive funnction Find-Depth-and-Set(v) which returns a pair (depth, representative), where depth is the depth of v in T_i and the representative is the root node of S_i. This will facilitate path compression.
(e) O(m lg*(n)) will be considered a tight bound.

12. [Group Problem] Group 3 grades this problem

A scorpion on n vertices is a graph that has a vertex of degree 1 (the tail), connected to a vertex of degree 2 (the body), connected to a vertex of degree n-2 (the head). The other n-3 vertices (the feet) can be arbitrarily interconnected. Give an O(n) algorithm for deciding whether or not an arbitrary graph is a scorpion, assuming that the graph is represented by an adjacency matrix.


B.D. Saunders
October 21,1999