Question: Need help optimizing case 1. Language is C++ // Program id: CSLab08.txt // This is our template for CS Lab 08 // Efficiency practice program

Need help optimizing case 1. Language is C++

// Program id: CSLab08.txt // This is our template for CS Lab 08 // Efficiency practice program // This document has three cases that represent portions of programs // that need some help; they are inefficient. // Study the code and rewrite or remove portions of the code // to make it more efficient. Your goal should be to decrease the number // of units (operations) by as much as possible. // We will assume a fictional chip where everything takes one cycle.

// UNITS:

// Mathematics (1 cycle) // Assignment (1 cycle) // Logical operations such compare operations, etc (1 cycle) // Return (1 cycle) // Hint: simply update this code for your answer by removing // the operations (code) that you find to be inefficient (unnecessary)... // // // CASE 1 // Assume all variables and constants were defined, etc. // This should be an easy one (short and sweet too)

for (i = 0; i < max; i++) myArray[i] = myArray[i] + sqrt(PI/2);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!