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


    Question

    In a backtracking algorithm, what happens when a partial

    solution is found to violate a constraint?
    A The algorithm immediately terminates. Correct Answer Incorrect Answer
    B The algorithm switches to a greedy approach. Correct Answer Incorrect Answer
    C The algorithm "backtracks" to a previous decision point and tries a different choice. Correct Answer Incorrect Answer
    D The algorithm stores the invalid path and continues exploring. Correct Answer Incorrect Answer
    E The algorithm re-evaluates all previous decisions. Correct Answer Incorrect Answer

    Solution

    The core idea of backtracking is to explore a path, and if that path leads to a dead end (violates a constraint or cannot lead to a solution), the algorithm "backtracks" by undoing the last decision and trying an alternative. This pruning of the search space is what makes backtracking efficient compared to brute-force enumeration.

    Practice Next
    ask-question