0

Can anyone tell me the efficient algorithm to calculate the transpose for Directed Graph for both Adjacency List and Adjacency Matrix Representations? Also, the time complexity of both the algorithms. Thanks in advance.

Nainy Jain
  • 177
  • 1
  • 9

1 Answers1

1

Iterate over all edges and reverse their direction. O(V+E) time for adjacency list and O(V^2) time for adjacency matrix.

ghui
  • 156
  • 3
  • 12