Data Structures and Algorithms
with Object-Oriented Design Patterns in C++
-
Complete the SetAsArray class
declared in Program
by providing suitable definitions for the following member functions:
SetAsArray (destructor), Purge,
IsEmpty, IsFull, Count,
Accept, and NewIterator.
Write a test program and test your implementation.
-
Complete the SetAsBitVector class
declared in Program
by providing suitable definitions for the following member functions:
SetAsBitVector (destructor), Purge,
IsEmpty, IsFull, Count,
Accept, and NewIterator.
Write a test program and test your implementation.
-
Rewrite the Insert, Withdraw and IsMember
member functions of the SetAsBitVector implementation
so that they use bitwise shift and mask operations
rather than division and modulo operations.
Compare the running times of the modified routines
with the original ones and explain your observations.
-
Complete the MultisetAsArray class
declared in Program
by providing suitable definitions for the following member functions:
MultisetAsArray (destructor), Purge,
Count, Accept, and NewIterator.
Write a test program and test your implementation.
-
Complete the MultisetAsLinkedList class
declared in Program
by providing suitable definitions for the following member functions:
SetAsArray (destructor), Purge,
IsEmpty, IsFull, Count,
CompareTo, Accept, and NewIterator.
Write a test program and test your implementation.
-
Design and implement a multiset class
in which the contents of the set are represented by
a linked list of ordered pairs of the form ,
where i an the element of the universal set U
and is a non-negative integer that counts the number
of instances of the element i in the multiset.
(See Exercises and ).
-
Write a program to compute the number of ways
in which a set of n elements can be partitioned.
I.e., compute
where
Hint: See Section .
Copyright © 1997 by Bruno R. Preiss, P.Eng. All rights reserved.