Question
Which traversal method is most suitable for finding
connected components in an undirected graph?Solution
Depth-First Search (DFS) is ideal for finding connected components in an undirected graph. Starting from an unvisited vertex, DFS explores all reachable vertices, marking them as visited. Each DFS call identifies one connected component, and the process is repeated for all unvisited vertices. Steps: 1. Initialize all vertices as unvisited. 2. Perform DFS from each unvisited vertex. 3. Each DFS traversal marks a connected component. DFS is efficient, with a time complexity of O(V+E), making it well-suited for sparse and dense graphs. Why Other Options Are Incorrect: 1. BFS: Can also find connected components but requires more memory due to queue-based implementation. 2. Topological Sort: Applies to Directed Acyclic Graphs (DAGs) and does not determine connected components. 3. Dijkstra’s Algorithm: Finds shortest paths, not connected components. 4. Floyd-Warshall Algorithm: Computes all-pairs shortest paths, unsuitable for this task.
'P' and 'Q' have present ages in the ratio of 4:5. If Q’s current age is increased by 20%, the gap between their ages becomes 1...
The ratio of A and B present age is 4:3. The product of their ages is 4800. What will be the ratio of their ages after 5 years?
- Average age of 24 employees is 35 years. If 4 employees resign, the average age drops to 34 years. Find the average age of the employees who resigned.
A’s age is 120% of what he was 4 years ago, But 30% of what it will be after 5 years. What is his present age?
- The present age ratio of R and S is 2:3. After 8 years, the ratio will be 3:4. Find the present age of S.
The current age of the mother is six times that of her daughter. In 12 years, the ratio of their ages will be 8:3. Determine the ...
The birth year of three siblings are consecutive. The present age of the eldest sibling is 10% more than the present age of the youngest sibling. What i...
‘A’ is 7 years younger than ‘B’ and 6 years elder than ‘C’. If the present age of ‘B’ and ‘D’ is 35 years and 24 years, respectively...
The ratio of A and B present age is 7:4. The product of their ages is 2800. What will be the ratio of their ages after 5 years?
- In a family, the mother is 3 years older than the father and four times as old as the son. If the sum of their present ages is 90 years, how many years lat...