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.
A costs thrice as much as B. A is sold at a loss of 15% and B is sold at 7/5th of its price. If selling price of A is Rs. 2300 more than selling price o...
The total cost price of 12 articles is the same as the total selling price of 7 articles. Calculate the percentage profit made on the sale of each arti...
Sundar bought 400 books for a total cost of Rs. 40,000. If 10% of the books are damaged due to rain, and 33â…“% of the remaining books are sold at the m...
Determine the original cost of a laptop if it was sold at a 20% profit for Rs. 24,000.
P purchased two items, a Table fan and a Ceiling fan, at the same cost price. She applied markups of 35% and 52% on the Table fan and Ceiling fan, respe...
A man purchased 100 rolls of paper for Rs. 60 per roll. He spent Rs. 750 on their transportation. He also paid 20 paise per roll for packing of each rol...
- A shopkeeper bought three items: a television for Rs. 10p, a refrigerator for Rs. 20p, and an air conditioner for Rs. 50p. The average price of these items...
A book is sold at two different prices. When sold at a loss of 22%, it fetches Rs. 165 less than when it is sold at a profit of 11%. What would be the s...
A trader bought an article for Rs. 3600 and marked it 20% above of its cost price. If he sold it after giving a discount of Rs. 180 then find the profit...
A merchant sold a gadget incurring a 30% loss. If he had marked up the price by 20% and then given a 15% discount, he would have earned Rs. 120 more. Fi...