Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(10 points) We compare the running time of two similar programs, given here in pseudo-code. Suppose we have an array A of 10,000 random integers,

image text in transcribed

(10 points) We compare the running time of two similar programs, given here in pseudo-code. Suppose we have an array A of 10,000 random integers, each between 0 and 99 , and we'll add the array elements that satisfy A[i]50. To make the time required more noticeable, we'll repeat that 100,000 times. for j in 0..9999 A[j]= a random number from 0 to 99 sum =0 for i in 0..99999 for j in 0..9999 if A[j]>=50 sum +=A[j] The second program is identical to the first, except we sort the array in place after the initialization. for i in 0..9999 A[i]= a random number from 0 to 99 sort_in_place (A) sum =0 for i in 0.99999 for j in 09999 if A[j]>=50 sum +=A[j] We measure the execution time of both programs, and find to our surprise that the second program runs noticeably faster than the first program! Explain where this miraculous performance increase came from. (You do not need to implement and run these functions yet. That comes in Assignment 1.)

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 And Expert Systems Applications 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

More Books

Students also viewed these Databases questions

Question

3. 'W11atc lni11iis tlus article 1nakii1g?

Answered: 1 week ago

Question

Explain how cultural differences affect business communication.

Answered: 1 week ago

Question

List and explain the goals of business communication.

Answered: 1 week ago