Algorithms - Algorithm Design Techniques

11. Complexity of Kruskal's algorithm for finding the minimum spanning tree of an undirected graph containing n vertices and m edges if the edges are sorted is ________.

  • Option : A
  • Explanation :
    O(m + n) Because, edges are sorted so , no need to make min heap, so deletion from min heap time is saved.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


12. Consider the following graph:

Which one of the following cannot be the sequence of edges added, in that order, to a minimum spanning tree using Kruskal's algorithm?

  • Option : D
  • Explanation :
    Ordering the weights, the sequence obtained is
    1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7
    Now, in order to obtain minimum spanning tree using Kruskal's algorithm, we have to add edges with weights in increasing order such that weight of the spanning tree is minimum.
    In option (D), weights of the edges are 1, 1, 2, 3, 2 which contradicts Kruskal's algorithm.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


13. Consider the following graph:

 Which one of the following is NOT the sequence of edges added to the minimum spanning tree using Kruskal's algorithm?

  • Option : D
  • Explanation :
    In Kruskal’s Algorithm we choose on edge of G which has smallest weight among the edges of G.
    So (b, e) = 2, (e, f) = 3, (b, c) = 4, (a, c)= 8, (f,g) = 4 (c,d) = 5

    Alternately
    Order the edges in non-decreasing order and pick edge one by one until all the nodes are completed with no edge making cycle on addition.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


14. Suppose we run Dijkstra's single source shortest-path algorithm on the following edge weighted directed graph with vertex P as the source.

In what order do the nodes get included into the set of vertices for which the shortest path distances are finalized?

  • Option : B
  • Explanation :

    nodes are include in order
    ⇒ (P, O, R, U, S, T)
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


15. Let G (V, E) an undirected graph with positive edge weights. Dijkstra's single source-shortest path algorithm can be implemented using the binary heap data structure with time complexity?

  • Option : D
  • Explanation :
    Using binary heap it requires
    O((|E| + |V|)log|V|)
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *