Algorithms - Algorithm Design Techniques

21. A undirected graph G has n nodes. Its adjacency matrix is given by an n x n square matrix whose
1. diagonal elements are 0's, and
2. non-diagonal elements are l's.
Which one of the following is TRUE?

  • Option : C
  • Explanation :
    In adjacency matrix if diagonal elements are 0’s and non-diagonal are 1’s then it is complete graph and in complete graph of n vertices total nn–2 Spanning trees are possible and cost of each tree. is (n – 1) because for n vertex graph, (n – 1) edges required in a tree.
Cancel reply
Cancel reply

23. Consider a weighted complete graph G on the vertex set {v1, v2,..., vn} such that the weight of the edge (vi, vj) is 2 |i - j|. The weight of a minimum spanning tree of G is

  • Option : B
  • Explanation :
    Minimum spanning tree of such a graph is

    Weight of the minimum spanning tree
    = 2|2 – 1| + 2|3 – 2| + 2|4 – 3| + 2|5 – 4| …. + 2| n – (n-1) |
    = 2n – 2
Cancel reply
Cancel reply

Common Data for Q. 25 & Q. 26

Suppose the letters a, b, c, d, e have probabilities
respectively

25. For the undirected, weighted graph given below, which of the following sequences of edges represents a correct execution of Prim's algorithm to construct a Minimum Spanning Tree?

  • Option : C
  • Explanation :

    In prims algorithm we can select arbitary vertex and them, find all the edges that connect the tree to new vertex and find the minimum and add it to the tree. So option “C” is correct
    (d, f), C), (d, a), (a, b), (c, e), (F, h), (g, h) (g, i).
Cancel reply
Cancel reply