Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

1. How will you, as city manager, handle these requests?

Answered: 1 week ago

Question

1. Identify the sources for this conflict.

Answered: 1 week ago