CS6140-Advanced 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. Input-output 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.
access the rest of the document.