Start learning 50% faster. Sign in now
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.
If the consonants are replaced by second succeeding letter and all the vowels are replaced by second preceding letter in the word ‘PORTABILITY’ as p...
All the letters provided below are arranged in English alphabetical order from left to right. Then in each combination, the first letter from the left e...
If all the letters in the word ‘LEVERAGE’ are arranged in alphabetical order from left to right such that the vowels are arranged first followed by ...
In the number ‘8984376589’, 1 is subtracted from all the odd numbers and 1 is added to all the even numbers. Now, in the obtained number, how many ...
If in the word DOMINATE, first all the consonants are arranged in alphabetical order from left to right and then all vowels are arranged in alphabetical...
If in the number '4735267843', '1' is added to all the odd digits and '2' is subtracted from the all the even digits then, all the digits are arranged i...
If all the vowels in the word ‘EXTREMELY’ are replaced by their immediate succeeding letter (in the alphabetical series) and then the letters are a...
If the letters of the word ‘OCCUPATIONAL’ are arranged in alphabetical order from the left end, then which letter (in the English alphabetical serie...
If each letter of the word ‘TERMINATE’ is replaced by its successor in the alphabetical series, then which of the following is third alphabet to the...
The positions of the first and the fifth digits in the number 74362581 are interchanged. Similarly the positions of the second and the sixth digits are ...