Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-1106· OpenAIHugging Face Arena Human Preference 55K

What would go wrong in BFS if I only add a node to the visited set right before I expand…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Hugging Facezephyr-7b-beta’s answer.
  1. User

    What would go wrong in BFS if I only add a node to the visited set right before I expand its neighbors?

  2. Assistant

    If you only add a node to the visited set right before you expand its neighbors in a breadth-first search (BFS), it would lead to visiting the same node multiple times. This defeats the purpose of using the visited set to prevent revisiting nodes and can result in inefficiency and unnecessary computation. The purpose of the visited set in BFS is to ensure that each node is visited exactly once, so adding a node to the visited set before expanding its neighbors helps in avoiding redundant visits and ensures the efficiency of the BFS algorithm.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.