hamburger menu
All Coursesall course arrow
adda247
reward-icon
adda247
    arrow
    arrow
    arrow
    In the following table, the left column contains the names of standard graph algorithms, and the right column contains the time complexities of the al
    Question



    In the following table, the left column contains the names of standard graph algorithms, and the right column contains the time complexities of the algorithms. Here, n and m are the number of vertices and edges, respectively. Match each algorithm with its time complexity.

    Choose the correct answer from the options given below:

    A.

    A - III, B - I, C - II, D – IV

    B.

    A - II, B - IV, C - III, D – I

    C.

    A - III, B - IV, C - I, D – II

    D.

    A - II, B - I, C - III, D – IV

    Correct option is A


    In question it is asked to match standard graph algorithms with their respective time complexities. Below is the detailed breakdown:
    Bellman-Ford Algorithm:
    · Used for single-source shortest path finding, even with negative weight edges.
    · Time complexity: O(n ⋅ m), where n is the number of vertices and m is the number of edges.
    Kruskal's Algorithm:
    · Used to find the minimum spanning tree in a weighted graph.
    · Time complexity: O(m ⋅ log n), as it involves sorting the edges and applying union-find operations.
    Floyd-Warshall Algorithm:
    · Used for finding shortest paths between all pairs of vertices in a weighted graph.
    · Time complexity: O(n3), since it iterates over all vertex pairs multiple times.
    Topological Sorting:
    · Used to linearly order vertices of a Directed Acyclic Graph (DAG).
    · Time complexity: O(n + m), as it involves visiting all vertices and edges once in a DFS or Kahn's Algorithm.
    Final Matching:
    A. Bellman-Ford Algorithm - III. O(n ⋅ m)
    B. Kruskal's Algorithm - I. O(m ⋅ log n)
    C. Floyd-Warshall Algorithm - II. O(n3)
    D. Topological Sorting - IV. O(n + m)
    Information Booster:
    1. Bellman-Ford Algorithm:
    · Works even with negative weight edges.
    · Detects negative weight cycles.
    2. Kruskal’s Algorithm:
    · Greedy algorithm.
    · Efficient when edges are significantly fewer than vertices.
    3. Floyd-Warshall Algorithm:
    · Dynamic Programming-based algorithm.
    · Inefficient for large graphs due to cubic complexity.
    4. Topological Sorting:
    · Linear ordering of DAG nodes.
    · Useful in task scheduling problems.
    Additional Knowledge:
    · O(n ⋅ m) is typical for graph traversal algorithms like Bellman-Ford.
    · Algorithms like Kruskal benefit from efficient edge sorting, hence O(m ⋅ log n).
    · O(n3) algorithms, such as Floyd-Warshall, are infeasible for very large graphs.
    · DAG-based algorithms, including topological sort, are usually O(n + m).

    test-prime-package

    Access ‘UGC NET Computer Science’ Mock Tests with

    • 60000+ Mocks and Previous Year Papers
    • Unlimited Re-Attempts
    • Personalised Report Card
    • 500% Refund on Final Selection
    • Largest Community
    students-icon
    329k+ students have already unlocked exclusive benefits with Test Prime!
    Our Plans
    Monthsup-arrow