小编da3*_*m0n的帖子

如何计算回溯算法的时间复杂度?

如何计算这些回溯算法的时间复杂度,它们是否具有相同的时间复杂度?如果不同怎么样?请详细解释并感谢您的帮助.

1. Hamiltonian cycle:

        bool hamCycleUtil(bool graph[V][V], int path[], int pos) {
            /* base case: If all vertices are included in Hamiltonian Cycle */
            if (pos == V) {
                // And if there is an edge from the last included vertex to the
                // first vertex
                if ( graph[ path[pos-1] ][ path[0] ] == 1 )
                    return true;
                else
                    return false;
            }

            // Try different vertices as a next candidate in Hamiltonian Cycle.
            // We don't try for 0 as …
Run Code Online (Sandbox Code Playgroud)

algorithm complexity-theory backtracking time-complexity

22
推荐指数
2
解决办法
4万
查看次数