Chat with us, powered by LiveChat GSP 215 Week 4 Homework Optimizing Program Performance NEW | Writedemy

GSP 215 Week 4 Homework Optimizing Program Performance NEW

GSP 215 Week 4 Homework Optimizing Program Performance NEW

ptimizing Program Performance

 

A programmer must write correct code that is clear and concise. There are also circumstances in which a programmer must write fast and efficient code. Processing video frames in real time must be fast. We will talk about ways to optimize code.

Given the following code, perform these operations to optimize the code. See Chapter 5 in the book for more details on code optimization. Please use comments to document all optimizations you have made to the code.

1.      Using switch instead of if

2.      Eliminating length calls out of the loop test

3.      Put the most used variables first when initializing variables

4.      Use prefix operations rather than postfix operations

5.      Loop unrolling—increase the number of elements computed in each iteration of a loop (i.e. instead of processing arrays separately, if you have two arrays of the same length, process them in parallel)

6.      Any other improvements you want to make

 

#include <iostream>

#include <vector>

#include <string>

using namespace std;

 

#include <iostream>

#include <vector>

#include <string>

using namespace std;

 

int main()

{

            //This program stores the items purchased at the grocery store. The price vector stores the prices for each item purchased.

            //The product name vector stores the products purchased and the category vector stores which category the item falls under.

            //Frozen foods have a 10% discount, snacks has a 5% discount, and produce has a 15% discount.

            //The total amount of items purchased should be calculated with a 7% tax rate.

       double sum;

            double tax,totalAmount;

 

            vector<double> price;

            vector<string>productName;

            vector<char> category;

           

            price.push_back(4.5);

            price.push_back(10);

            price.push_back(1.25);

            price.push_back(2.75);

            price.push_back(9.50);

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order