Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A vertex v in a directed graph G is called a sink if: all other vertices of G have an edge that points to v,

A vertex v in a directed graph G is called a sink if:

all other vertices of G have an edge that points to v, and

no vertex in G, including v itself, has an edge that points from v.

Given the (partial) definition of an adjacency matrix below, complete the C# method Sink which returns true if the given vertex v (name) is both found and a sink; false otherwise. Note that E[i,j] = -1 when the edge from i to j does not exist. State the worst-case time complexity of your Sink method using the big-Oh notation where n is the number of vertices.

class DirectedGraph

{

public string[ ] V { set; get; } // Vertex list

public int[,] E { set; get; } // Adjacency matrix

public int NumVertices { set; get; }

public int MaxNumVertices { set; get; }

...

// FindVertex

// Returns the index of the given vertex (if found); otherwise returns -1

private int FindVertex (string name) { ... }

...

public bool Sink (string name) { ... }

}

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

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions

Question

1-5 Technology and culture create a new always-on consumer.

Answered: 1 week ago