Question: Write a program in C++ for the following: prufergraph1.txt: 6 5 1 2 3 4 3 5 1 3 1 6 Write a program to

Write a program in C++ for the following:

Write a program in C++ for the following: prufergraph1.txt: 6 5 1

prufergraph1.txt:

6 5 1 2 3 4 3 5 1 3 1 6 

Write a program to compute the Prufer sequence of a tree. Your program should take the name of a graph file as a command line argument and output the Prufer sequence of the graph if it is a tree. If the graph is not a tree, your program should output a message to that effect, and no sequence. (Note that forests are not trees, so simply checking that there are no remaining degree one vertices will not be sufficient by itself to test whether a graph is a tree. For this assignment, we are assuming that the vertices of the graph are labeled 1 to n rather than 0 to n-1. The output should look very similar to the following two examples /findprufer seguence pufergraph1.txt 1 3 3 1 /findprufer sequence pufergraph2 txt not a tree

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!