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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started