SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 1 Day Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 30 Nov 2017 My Price 10.00

different operations can amount of time to complete.

Would like help with Part B of this lab. Only need part B.

Week 4 Lab—Optimizing Program Performance

 

TCO 4—Given the importance of speculating runtime costs of software, obtain an understanding of certain details of how processors operate that impact code performance.

 

 

Scenario

In this week’s lab, you will look at timing operations and how different operations can take a different amount of time to complete.

 

Rubric

 

Point distribution for this activity

Lab Activity

Document

Points possible

Points received

Part A

20

 

Part B

20

 

Total Points

40

 

 

 

 

Part A:

We will look at timing operations in C++. To see the difference in operations, write C++ code to compare cout and printf, and display the time difference for 100 cout operations and 100 printf operations. This code can be written in Visual Studio. Below is how you would time the 100 cout operations in Visual Studio. Add another for loop, and display time for both cout and printf then comment about why you think there is a difference.

#include<iostream>

#include<time.h>

usingnamespace std;

 

int main()

{

       double start, stop;

       start=clock();

       for (inti=0;i<100;i++)

       {

              cout<<" The number is "+i<<endl;

       }

 

       stop =clock();

cout<<"It took "<<(double(stop-start)/CLOCKS_PER_SEC)<<" seconds for cout"<<endl;

cin.ignore();

}

 

C++ code:

 

 

Screenshot of output:

 

 

 

Why is one faster than the other?

 

 

 

 

Part B:

Next, we will take timing a step further. There are a few different sorting algorithms, and these algorithms have varying time complexity. For this part of the lab, we will implement bubble sort and quick sort. Research bubble sort and quick sort algorithms, and implement them in C++. Fill a large array (maybe 15,000 elements) of random numbers. Then time the difference between bubble sort and quick sort 10 times, and fill out the table. Next, run the program in release mode. Did you notice a difference in time?

 

 

 

 

Copy your C++ code here.

 

 

Debug mode:

 

Iteration

Bubble sort time

Quick sort time

1

 

 

2

 

 

3

 

 

4

 

 

5

 

 

6

 

 

7

 

 

8

 

 

9

 

 

10

 

 

Release mode:

Bubble sort time: _________________________

Quick sort time: __________________________

 

 

 

 

Example output

 

Answers

(5)
Status NEW Posted 30 Nov 2017 11:11 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)