Answered step by step
Verified Expert Solution
Question
1 Approved Answer
prufergraph1.txt: 6 5 1 2 3 4 3 5 1 3 1 6 prufergraph2.txt: 6 4 1 2 3 4 3 5 1 6 Write
prufergraph1.txt:
6 5
1 2
3 4
3 5
1 3
1 6
prufergraph2.txt:
6 4
1 2
3 4
3 5
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 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 treeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started