CSC 141: Assignment 1
Due on Monday 11 Oct
Michalis Faloutsos
Important: you should keep checking the news-group for updates: ucr.cs.141.
I . Written part.
Questions from the book. It should be handed in on the class of the
due date.
-
5.4-4
-
5.4-5
-
5.5-2. Find a graph for n=7, and then try to generalize for n>7.
-
5.5-5
-
5.5-7. Tips: Compare a non-complete binary tree of height h with a complete
binary tree of the same height. Then compare complete binary trees of different
height.
-
23.1-1
II. Programming part.
We want to write a program in C++ that will represent graphs. The
program should read a file with the graph data, convert it into an adjacency-list
representation.
In more detail, the data file should be in the format, total number
of nodes and then pairs of nodes that are connected with an edge:
30
1 2
2 3
2 1
.........
n1 n2
Note that n1 n2 means the edge in the direction from n1
to n2 and not the other way. (This way, we can define directed graphs.)
We want to implmement the following classes:
-
class Graph;
-
class Node;
-
class Edge;
Down-load the definitions and complete
the methods that are missing. The contructors and destructors of each class
are not listed but they should be implemented. Feel free to write auxiliary
methodss. Your code should be documented: every method should have a brief
one or two line explanation. You should have the program in multiple files:
header.h, [class].cc, main.cc. You should compile it with the use
of a makefile. Your wonderful TA, Michael, will explain this in the lab
and provide some makefile samples.
What to submit
-
1-2 page report explaining what you did and how, what you did not do, a
sample output. The grader should be able to grade the assignment by just
reading the report. However, the grader will check out your program and
your programming style.
WARNING: A report that makes false claims about the program
is a serious offense.
-
Electronically: submit your program ready to compile and a README file
for instructions on how to run it.
The program is due on 11:59 pm of the due-date
.