In BFS, to avoid infinite loops in graphs with cycles, a _______ data structure is used to keep track of visited nodes.
- Hash Table
- Linked List
- Queue
- Stack
In BFS, to avoid infinite loops in graphs with cycles, a queue data structure is used to keep track of visited nodes. The queue ensures that nodes are explored in the order they are discovered, preventing cycles.
Loading...
Related Quiz
- Insertion Sort is particularly effective when the input array is nearly _______ sorted.
- Imagine you're sorting a large dataset stored on disk using Quick Sort. How would you mitigate the risk of running out of memory during the sorting process?
- The time complexity for finding the kth element from the end of a singly linked list using two pointers is _______.
- How can the longest common substring problem be extended to handle multiple strings?
- The Floyd-Warshall algorithm has a time complexity of _______ and is suitable for finding the shortest paths between all pairs of vertices in a graph.