📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    When implementing a `Graph` traversal algorithm like

    Depth-First Search (DFS) recursively, what is the primary control flow mechanism that manages the order of visiting nodes and backtracking? 
    A An explicit `Stack` data structure managed by the programmer. Correct Answer Incorrect Answer
    B The implicit call stack maintained by the programming language for function calls. Correct Answer Incorrect Answer
    C A `Queue` data structure for breadth-first exploration. Correct Answer Incorrect Answer
    D A `for` loop iterating over all possible paths. Correct Answer Incorrect Answer

    Solution

    In a recursive DFS, the "stack" that manages the order of node visits and backtracking is the program's own call stack. Each recursive call pushes a new frame onto the stack, and when a call returns, its frame is popped, effectively backtracking.

    Practice Next
    ask-question