/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Q14E The chapter suggests an alternat... [FREE SOLUTION] | 91影视

91影视

The chapter suggests an alternative algorithm for linearization (topological sorting), which repeatedly removes source nodes from the graph (page 101). Show that this algorithm can be implemented in linear time.

Short Answer

Expert verified

Answer is not given by the question.

Step by step solution

01

Linearization topology sorting.

Topological sorting

The topological sorting is the traversing of directed acyclic graph in order to get a topological order in a way that the output in decreasing order of post number

Some properties ofTopological sorting are as follows

1). The topological ordering is basically a linear ordering of graph if u and v are the vertices of graph their u must be comes before v.

2). It must be a DAG (directed acyclic graph)

3). The given graph should be directed acyclic graph with no cycle.

4). Every directed acyclic graph must contain at least onetopological ordering.

5). It takes linear time for processing.

02

Proving the algorithm.

In first step check whether the graph has cycle or not. If not then proceed for topological ordering.in the above graph it does not contain any cycle in it then proceed it to the next step.

03

Find the degree of the vertices.

Now find out the node with in degree zero and consider it as source vertex.

In degree of any node is the number of edges which directs towards it.

So, here A has in degree zero and B also contain zero as its in degree. Now select anyone from these vertices.

Let A as its source vertex.

04

Find the cycle and degree.

After selection of A select as its next node because its in degree is zero. And removes source nodes from the graph.

So, after removing both of the vertices, it seems that C has degree 0 and D has 1 in degree. Than select C , up to here the sequence of graph is ABC .

Than eliminate C .now the degree of D and E again zero. Select any one from them. Select D and after that select E. Now the degree of F is zero and the degree of G and H is 1 . After selecting F eliminate F and again look for degree and the degree of both G and H is zero because no other edge is coming on these nodes let select G and after that select H. Similarly apply this method on each and every vertex.

Then the sequence is, ABCDEFGH

05

Evaluate all possible cases.

Similarly, by selectingas first edge other three case is possible through this they are as follows,

ABCDEFGHABCEDFGHABCEDFHGABCDEFHG

Now the next possibility is when the source node as B and after that select A as the next vertex now again find the degree of the each and every node in the graph after eliminating both vertex A and B then it is clear the new degree of C is zero. So, select C . Again D and E are the two option select each of them one by one for showing various possibility.

Then select in one case EFGH .

The other four cases are as follows:

BACEDFHGBACDEFHGBACDEFGHBACEDFGH

It takes linear time for processing.And, there are 8 topological orders are possible in the graph.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91影视!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

You are given tree T=(V,E) along with a designated root node rV. The parent of any node Vr, denoted p(V), is defined to be the node adjacent to v in the path from r to v . By convention, p(r)=r. For k>1, define pk(v)pk-1(pv)andp1(v)=p(v)(so pk(v)is the k th ancestor of v ). Each vertex v of the tree has an associated non-negative integer label l(v). Given a linear-time algorithm to update the labels of all the vertices T according to the following rule: lnew(v)=l(plvv).

Run the DFS-based topological ordering algorithm on the following graph. Whenever you have a choice of vertices to explore, always pick the one that is alphabetically first.

(a) Indicate the pre and post numbers of the nodes.

(b) What are the sources and sinks of the graph?

(c) What topological ordering is found by the algorithm?

(d) How many topological orderings does this graph have?

Give an efficient algorithm that takes as input a directed acyclic graph G=V,E, and two vertices s,tV, and outputs the number of different directed paths from S to t in G.

Infinite paths.Let G=(V,E) be a directed graph with a designated 鈥渟tart vertex鈥 sV,asetVGV, a set of 鈥済ood鈥 vertices, and a set VBV of 鈥渂ad鈥 vertices. An infinite trace of is an infinite sequence of vertices viV such that (1)v0=s, and (2) for all i0, (vi,vi+1)E. That is, p is an infinite path in G starting at vertex s. Since the setV of vertices is finite, every infinite trace of Gmust visit some vertices infinitely often.

  1. If p is an infinite trace, let Inf(p)V be the set of vertices that occur infinitely often in p. Show that Inf(p) is a subset of a strongly connected component of G.
  2. Describe an algorithm that determines if role="math" G has an infinite trace.
  3. Describe an algorithm that determines if G has an infinite trace that visits some good vertex in VG infinitely often.
  4. Describe an algorithm that determines if role="math" localid="1659627728759" G has an infinite trace that visits some good vertex in VG infinitely often, but visits no bad vertex in VB infinitely often.

Either prove or give a counterexample: if {u,v}is an edge in an undirected graph, and during depth-first search (u)<post (v), then vis an ancestor of uin the DFS tree.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.