Question: Compute both the average and worst case Give the detailed running time that includes all multipliers and the actual constant. To compute constants, ONLY count
Compute both the average and worst case
Give the detailed running time that includes all multipliers and the actual constant. To compute constants, ONLY count assignment statements (do not try to evaluate the running time of a for loop header).
1.
int CheckGravity() { // nextVertex, V, min, hold are all integers for (src=0; src 2.
int nextAdj(int from, int last) { i=last+1; index=0, found=0; while (i < N) { if (AdjMat[from][i] == 1) { index=0; found=0; while(CurGravityPath[index] != -1 && !found){ if(CurGravityPath[index] == i) found=1; else index++; } if (!found) return i; } i++; } return -1; } 3.
void Exhaustive() { for (i=0; i < N; i++) { for (j=0; j < N; j++) { if (AdjMat[i][j] == 0) PathLengths[i][j]=999999999; else { PathLengths[i][j]=1; } } PathLengths[i][i]=0; } for (k=0; k 4.
void Permute(int n){ if (n == 1) { return; } else { for (i=0; i < n; i++) { Permute(n-1); tmp=Gravity[n-1]; if (n % 2 == 1) //n is even { Gravity[n-1]= Gravity[0]; Gravity[0]=tmp; } else // if n is even { Gravity[n-1]= Gravity[i]; Gravity[i]=tmp; } } } }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
