Algorithms - Algorithm Design Techniques

46. What is the time complexity of Bellman -Ford single-source shortest path algorithm on a complete graph of n vertices?

  • Option : C
  • Explanation :
    Given: A complete graph on n vertices?
    To find: Time complexity of Bellman-Ford Single source shortest path.
    Analysis: Time complexity of Bellman-ford algorithm on a graph with n vertices and m edges is O(nm) For a complete graph, m = nC2 = 0(n2) (Since, there is an edge between all pair of vertices)
    ∴ Time Complexity = 0(n2.n) = 0(n3)
    ∴ Solution is (C)
    Note : Include vertex of degree zero in even degree vertices.
Cancel reply
Cancel reply

49. Let A1 , A2 , A3 and A4 be four matrices of dimensions 10 × 5, 5 × 20, 20 × 10, and 10 × 5, respectively. The minimum number of scalar multiplications required to find the product A1 A2 A3 A4 using the basic matrix multiplication method is _________.

  • Option : A
  • Explanation :
    Using matrix chain multiplication the optional way to multiply is
    A1 × (A2 × A3 ) × A4
    = (5 × 20 × 10) + (5 × 10 × 5) + (10 × 5 × 5)
    = 1500.
Cancel reply
Cancel reply

50. Which one of the following algorithm design techniques is used in finding all pairs of shortest distances in a graph?

  • Option : A
  • Explanation :
    All pair shortest path Algorithm is Application of Dynamic Programming
Cancel reply
Cancel reply