This preview shows page 1. Sign up to view the full content.
CS6140Advanced Programming Lab
Exercise 1
Due 17th August 2010 2:00 PM
Write C++ programs to implement the following graph traversal algorithms algorithms.
1. Breadth ﬁrst traversal : This algorithm has to be implemented using Queue ADT
2. Recursive depth ﬁrst traversal
3. Iterative depth ﬁrst traversal : Here you have to create your own Stack ADT
Note 1: Both ADTs Queue and Stack has to be implemented using Linked Lists.
Note 2: Given input graphs could be disconnected.
Inputoutput formats:
Input format is same for all the above problems. Your program must take two ﬁle names as inputs from the
user. Graphs will be provided in the input ﬁle and you should print its traversals in the output ﬁle. The
input ﬁle will contain several test cases, each test case spans over several lines and every test case is ended
by single $ sign. Format of each test case is explained here using adjacency list representation. First line
contains n,m, where n represents number of vertices and m represents number of edges of graph. Adjacency
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 09/08/2010 for the course COMPUTERSC cs5800 taught by Professor Narayanaswamy during the Spring '10 term at Indian Institute of Technology, Chennai.
 Spring '10
 narayanaswamy

Click to edit the document details