Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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 tree

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

1. What are your creative strengths?

Answered: 1 week ago