Answered step by step
Verified Expert Solution
Link Copied!

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; 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

1. List your top 10 film heroes.

Answered: 1 week ago

Question

4-6 Is there a digital divide? If so, why does it matter?

Answered: 1 week ago