edited by
603 views
0 votes
0 votes

Suppose we have a directed graph G = (V,E) with V= {1, 2, ..., n} and Eis presented as an adjacency list. For each vertex u in V, out(u) is a list such that (u, v) in {1, 2, ... k). For each u in V, we wish to compute a corresponding list in(u) =such that in E for each i in {1, 2, ... k'). Let n be the number of vertices in Vand m be the number of edges in E. How long would it take to construct the lists in(u), u in V, from the lists out(u), u in V?

  1. T(n) =O(n+m)            B. T(n)= O(n(m+n))

 

edited by

1 Answer

0 votes
0 votes
question is about finding the in-degree and out-degree or vertices .

to find in-degree and out-degree TC = O (V + E)  where V is no of vertices and E no of edges.(using adjacency list).

 

Ans : O( m + n)

Related questions

575
views
1 answers
0 votes
Ray Tomlinson asked Aug 9, 2023
575 views
Numerical Answer Type Que?(please Try to give some ahortcut trick also or important concept is there to solve that question )
932
views
1 answers
2 votes
Ray Tomlinson asked Aug 9, 2023
932 views
You are given an array of elements where each array element represents the MAXIMUM number of jumps that can be made in the forward direction from that element. Now, consi...
216
views
0 answers
0 votes
Sajal Mallick asked Nov 27, 2023
216 views
As we have to select maximal set of “non overlapping” activities. So like job scheduling algo of greedy we can solve it. So according to that complexity must be O(n l...
968
views
1 answers
1 votes
Ray Tomlinson asked Aug 9, 2023
968 views
Which of the following statement(s) is/are true?(a) Quicksort and merge sort are both examples of divide and conquer algorithms.(b) If we randomly choose a pivot element ...