edited by
1,429 views
0 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))

 

$\left[v_{1}, v_{2}, \ldots v_{k}\right]$ such that $\left(u, v_{i}\right)$

$\left[v_{1}, v_{2}, \ldots v_{k}^{\prime}\right]$

$(v, u)$

1 Answer

0 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)
Position:
Show:

Related questions

0 0 votes
1 1 answer
1.4k
1.4k views
aashish1406 asked Aug 9, 2023
1,424 views
Numerical Answer Type Que?(please Try to give some ahortcut trick also or important concept is there to solve that question ) Suppose the hash function were instead $h(k)...
2 2 votes
1 1 answer
1.4k
1.4k views
aashish1406 asked Aug 9, 2023
1,443 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...
3 3 votes
1 1 answer
2.4k
2.4k views
aashish1406 asked Aug 9, 2023
2,391 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 ...
0 0 votes
1 1 answer
525
525 views
Sajal Mallick asked Nov 27, 2023
525 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 logn)...