Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

9. (30 points) Write a C++ program called ts.cpp that implements the topological sorting algorithm based on the source-removal algorithm. Your program should read an

image text in transcribed

image text in transcribed

9. (30 points) Write a C++ program called ts.cpp that implements the topological sorting algorithm based on the source-removal algorithm. Your program should read an input file name. Then it should display the topological ordering. In the problem, you can assume that the number of vertices in the input file is less than 50. Additionally, you can assume that the input graph is always a DAG (=Directed Acyclic Graph). When you write the program, don't forget to include "Title", "Abstract", "ID (A four- digit number)", "Name", and "Date": Input file format: This is a sample input file called ti.txt. 010 001 000 The first line = 3 in the example) indicates that there are three vertices in the graph. For the homework, we can assume that the first vertex starts from the number 0. Thus, tl.txt describes a directed graph like below: One blank space is used to delimiter the data. Note that there's no blank space at the end of each line. If your program does not read the file properly, your program will get no credit. The following presents a sample run of the program. Your program should be compiled and executed exactly like this. Enter filename: C:\\tmp\\ti.txt Topological sort: 0 -> 1 -> 2 In the program, your program has to follow our convention (= ascending order). This is another sample input file called t2.txt. 00100 00100 00011 00001 0 0 0 0 0 Page 4 of 5 This is a sample run: Enter filename: C:\\tmp\\t2.txt Topological sort: 0 -> 1 -> 2 -> 3 -> 4 Again, your program must follow our convention (= ascending order). So, your program should remove the vertex O first between the two source vertices 0 and 1

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

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

What different skills and behaviours will be needed?

Answered: 1 week ago

Question

expotential smoothing

Answered: 1 week ago