This is a code in C, I need to change the code as much as possible, but on condition to perform the same work as this. Changing the var names and the loops is enough
void ExtractMinimumWeightPath(int path[MAX], int weights[MAX][MAX], int pathWeights[MAX][MAX], int rowc, int colc)
{
int rowsCount = rowc;
int colsCount = colc;
path[rowsCount];
int col = 0;
int i = 0;
for(i=1;i<colsCount;i++)
{
if(pathWeights[rowsCount-1][i]<pathWeights[rowsCount-1][col])
{
col = i;
}
}
int row = rowsCount-1;
do
{
path[row] = col + 1;
if (col>0 && pathWeights[row-1][col-1] + weights[row][col] == pathWeights[row][col])
{
col = col - 1;
}
else if (col < colsCount-1 && pathWeights[row-1][col+1] + weights[row][col] == pathWeights[row][col])
{
col = col + 1;
}
row--;
}
while(row>0);
path[0] = col + 1;
}
This is a code in C, I need to change the code as much as possible, but on condition to perform the same work as this.
Changing the var names and the loops is enough
Step by step
Solved in 2 steps
- Recommended textbooks for youDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag…Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education