Algorithm study notes




A general recursive template for backtracking:

   helper (parameters of given data and current recursive level) {
        // Handle base cases, i.e. the last level of recursive call
        if (level == lastLevel) {
            record result;
            return sth;
        // Otherwise permute every possible value for this level.
        for (every possible value for this level) {
            helper(parameters of given data and next recursive level);
        return sth;


About the Author


Leave a Reply

Your email address will not be published. Required fields are marked *