Question

Consider these two programs: Program A for (i = 1; i<n; i++){ Z[i] = X[i] - Y[i] Z[i] = Z[i] * Z[i] Program B for (i=1;i<n; i

0 0
Add a comment Improve this question Transcribed image text
Answer #1

******************************************************************************************
Please Upvote the answer as it matters to me a lot :)
*****************************************************************************************
As per HomeworkLib expert answering guidelines,Experts are supposed to answer only certain number of questions/sub-parts in a post.Please raise the remaining as a new question as per HomeworkLib guidelines.
******************************************************************************************

a)
both the programs perform the sum of the squares of the differences
of the two sequences stores in arrays x and y from index 1 to n-1
b)
program A performs better as it has fewer instructions
i=1 is initialized only once in program A whereas 2 times in program B
i<n condition is checked n times in program A whereas 2*n times in program B
i++ condition is executed n times in program A whereas 2*n times in program B

Add a comment
Know the answer?
Add Answer to:
Consider these two programs: Program A for (i = 1; i<n; i++){ Z[i] = X[i] -...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT