Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please fix the function code blow: in the for loop, I want end the loop when i and j both equal to 0. And when

Please fix the function code blow:

in the for loop, I want end the loop when i and j both equal to 0. And when only one of them equal to 0 the loop will continue running.

I use i!=0&&j!=0 for the condition, but the loop ends when one of i or j equal to 0, it should continue running until both of them equal to 0. I don't know what's wrong with my for loop function. The code is blew:

for(i=len1,j=len2;i!=0&&j!=0;)

{

if((min[i][j]==min[i-1][j-1])&&(word1[i-1]==word2[j-1])) { path1[max(i,j)-1]=word1[i-1]; path2[max(i,j)-1]=word2[j-1]; cost[max(i,j)-1]='.'; i--;j--; } else if(min[i][j]==min[i-1][j-1]+1) { path1[max(i,j)-1]=word1[i-1]; path2[max(i,j)-1]=word2[j-1]; i--;j--; }

else if(min[i][j]==min[i-1][j]+1) { path1[max(i,j)-1]=word1[i-1]; path2[max(i,j)-1]='-'; i--; } else if(min[i][j]==min[i][j-1]+1) { path1[max(i,j)-1]='-'; path2[max(i,j)-1]=word2[j-1]; j--; }

}

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

Beginning PostgreSQL On The Cloud Simplifying Database As A Service On Cloud Platforms

Authors: Baji Shaik ,Avinash Vallarapu

1st Edition

1484234464, 978-1484234464

More Books

Students also viewed these Databases questions

Question

Presentation Aids Practicing Your Speech?

Answered: 1 week ago