Problem 1
This past week we used the node class to define singly linked lists.
The node class and the associated linked list toolkit are
given in the files: listNode1.h and
listNode1.cxx.
Modify the node class and the linked list toolkit
so that any node object can contain any
type of information in its data field.
To test your implementation of the templated node class, compile and
execute the following program testNode.cxx
that uses the templated node class.
Submit printouts of (i) your templated node class and the new linked list
toolkit and (ii) the output produced when testNode is executed.
Note:
using namespace main_savitch_5;
Problem 2
Implement a simple templated graph class using the
adjacency list representation (as discussed in the lectures).
Templating the graph class will allow the names of vertices to
have arbitrary types (not just the string type).
Use the following data members:
apvector < node < T > > myVertices; int myNumVertices; int myNumEdges;and define and implement the following member functions:
Submit a printout of your graph class, the ladder program, and the information on number of neighbors mentioned above.
Problem 3
Write a recursive function that takes two positive integers
n and k, k < n, and produces as output all subsets of size k of
the set {1, 2, ..., n}.
Submit a printout of your function and submit the output produced
by this function when called with n = 8 and k = 4.