445 views
2 votes
2 votes
If the worst case time complexity by the best algorithm for finding the outdegrees and indegrees of all the vertices (extra space can be used if required) in a dense graph of $n$ vertices (number of edges $= \Theta(n^2))$ represented in Adjacency List format is given by $\Theta(n^a \log ^b n)$ and $\Theta(n^c \log ^d n)$ respectively, $2\times a + 3 \times b + 5 \times c + 7 \times d = $ _____

1 Answer

Best answer
7 votes
7 votes
The out-degree of each vertex will be the number of vertices in its adjacency list. So, for all the vertices, we can get the out-degree in $\Theta(m+n)$ time where $m$ is the number of edges. Since $ m = \Theta(n^2),$ this will give $\Theta(n^2).$

In-degree can also be computed in $\Theta(m+n)$ time by maintaining an array of size $n$ for the vertices and then traversing all the adjacency lists. Whenever we encounter a vertex we increment the corresponding entry in the array.

Thus, we get $a = c = 2, b = d = 0.$

$2\times a + 3 \times b + 5 \times c + 7 \times d = 14.$
selected by
Answer:

Related questions

4 votes
4 votes
2 answers
1
gatecse asked Sep 7, 2020
299 views
Consider the following directed graph.The number of different topological orderings of the vertices of the graph is $\_\_\_\_\_\_\_\_.$
5 votes
5 votes
1 answer
2
gatecse asked Sep 7, 2020
199 views
Consider a complete graph $G$ with $6$ vertices. The graph $G$ has ________ spanning trees.
7 votes
7 votes
1 answer
3