Code Random Notes--Backtracking Algorithms

1--Theoretical basis of backtracking algorithm

        The backtracking algorithm is essentially a violent search process, which is often used to solve problems such as combination , cutting , subset , and permutation . Its general template is as follows:

void backTracking(参数){
    if(终止条件){
    // 1. 收获结果;
    // 2. return;
    }

    for(..遍历){
        // 1. 处理节点
        // 2. 递归搜索
        // 3. 回溯 // 即撤销对节点的处理
    }
    return;
}

2--combination problem

Guess you like

Origin blog.csdn.net/weixin_43863869/article/details/132722009