Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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; src2.
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; k4.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started