Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In class we saw an algorithm for finding a topological sort of the vertices in a directed, acylic graph. The algorithm was based on finding

In class we saw an algorithm for finding a topological sort of the vertices in a directed, acylic graph. The algorithm was based on finding v.indgree for each vertex in the graph, and it used an external list L.
1. Compute in-degree of each vertex and store the in-degree in v:indegree.
2. For all v 2 V , if v:indegree =0 then add v to the list L.
3. Repeat until L is empty:
Remove a vertex u from L and place it at the end of T.
For all v in Adj [u]
v:indegree = v:indegree -1.
if v:indegree =0
add v to L
Suppose we wish to update this algorithm in order to solve the following problem:
Let G be a directed, acyclic graph, where each vertex has a diculty rating, v.rate. The problem is to find a topological ordering of the vertices, one which prioritizes vertices of low rating before vertices of high rating. For example, if several orderings are possible, the goal is to prioritize vertices of lowest rating before those of higher rating, as long as it respects the topological sort.

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_2

Step: 3

blur-text-image_3

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

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

What is desktopmanagement, andwhy is it important?

Answered: 1 week ago