What is the time complexity of Binary Search when searching for an element in a sorted array with n elements?
A) O(1)
B) O(log n)
C) O(n)
D) O(n log n)
B) O(log n)
Binary Search has a time complexity of O(log n) when searching for an element in a sorted array with n elements.
72
In which scenario should you consider using Topological Sort?
A) Calculating the shortest path in a weighted graph.
B) Finding the strongly connected components in a directed graph.
C) Detecting a cycle in an undirected graph.
D) Scheduling tasks with dependencies.
D) Scheduling tasks with dependencies.
Option C is incorrect because Topological Sort is not typically used for detecting cycles in undirected graphs. Instead, it is primarily used for directed acyclic graphs (DAGs).