Question
Which of the following algorithms is best suited for
finding the shortest path in a weighted graph where some edges may have negative weights but no negative cycles?Solution
The Bellman-Ford Algorithm (C) is best suited for finding the shortest path in graphs that may have negative weights but no negative cycles. It works by relaxing the edges up to (V-1) times, where V is the number of vertices, ensuring it can handle negative weights and detect negative cycles. Why Other Options Are Wrong: A) Dijkstra's Algorithm: Dijkstra’s algorithm is faster than Bellman-Ford for graphs with non-negative weights but fails when negative weights are present, as it assumes all edge weights are positive. B) Kruskal's Algorithm: This is a Minimum Spanning Tree (MST) algorithm used to connect all nodes in a graph with minimum weight, not to find the shortest path between two nodes. D) Prim’s Algorithm: Like Kruskal’s, Prim’s algorithm is used for finding an MST, not for finding the shortest path in a graph with negative weights. E) Floyd-Warshall Algorithm: This algorithm computes shortest paths between all pairs of vertices and works for both positive and negative weights, but it is not optimal for solving single-source shortest path problems.
What best defines "valuable security" under Section 2(31)?
Chapter VII of The Indian Evidence Act, 1872 deals with________.
Nothing is an offence which is done by a child under ……. Of age
Who establishes the Data Protection Board of India?
What is the limitation period for filing a suit for a breach of contract under the Limitation Act?Â
Order XIX of the Code of Civil Procedure, 1908 related to __________.
Under the Trade Union Act, 1926, Section 24 requires what is the minimum number of persons required to apply for registration of a trade union?
Under the proviso to Section 8B(1), the Commission may extend the six-month investigation period by:
What is e-commerce?
Who can try offences under the Trade Union Act 1926?