Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We again consider directed graphs, with nodes 1..n and with a edges (this time without weights). Our aim is now to reverse the graph; that

image text in transcribed

We again consider directed graphs, with nodes 1..n and with a edges (this time without weights). Our aim is now to reverse the graph; that is, from a given graph (V, E) we want to construct a graph (V, E) such that for all i and k in V, E contains an edge fro to k iff E contains an edge from k toi 1. (10p) First assume the graph is represented as an adjacency matrix A, with the boolean A(i, k) true iff the graph has an edge fromi to k. Write an algorithm to implement this specification, and analyze its running time, as a function of n and of a 2. (5p) Next assume the graph is represented as adjacency lists L (that is, for cachi e 1..n, the list L[i] contains the targets of edges with source i). Then the specification can be implemented by the algorithm below (where CONs adds an edge to a list of edges) whose running time, as a function of n and of a, you must analyze. for k 1 to n ,[A] EMPTY or i 1 to n foreach k E Li

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

Students also viewed these Databases questions