小编use*_*495的帖子

如何计算反向跟踪算法的时间复杂度

使用过这个程序,如何计算回溯算法的时间复杂度?

/*
  Function to print permutations of string    This function takes three parameters:
  1. String
  2. Starting index of the string
  3. Ending index of the string.
*/ 
void swap (char *x, char *y)
{
  char temp;
  temp = *x;
  *x = *y;
  *y = temp;
}

void permute(char *a, int i, int n)
{  
  int j;

  if (i == n)
    printf("%s\n", a);
  else
  {
    for (j = i; j <= n; j++)
    {
      swap((a+i), (a+j));
      permute(a, i+1, n);
      swap((a+i), …
Run Code Online (Sandbox Code Playgroud)

c algorithm time-complexity

3
推荐指数
1
解决办法
3321
查看次数

标签 统计

algorithm ×1

c ×1

time-complexity ×1