Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Perform careful experimental analysis of their running times by doing the following: a. For each algorithm, choose at least 5 appropriate values for n ,

  1. Perform careful experimental analysis of their running times by doing the following:
  2. a. For each algorithm, choose at least 5 appropriate values for n, where n is the input array size, and determine how long it takes to run in microseconds. Please note the following:

  • One good strategy is to grow the input size by repeated doubling (e.g 200000,400000,800000, etc).
  • If your timings are erratic (e.g. 0s or there is no clear increase in time with respect to input size), try choosing larger values for n.
  • You are not required to use the same values of n for both algorithms.

  1. Plot the running times obtained in part (a) as a function of n as scatter plots on a linear scale for each algorithm.

image text in transcribed

Algorithm prefixAveragesi (x): Input: An n-element array X of numbers. Output: An n-element array A of numbers such that A[i] is the average of elements X(O).....X[i]. Let A be an array of numbers. for i = 0 to 1-1 do 40 for jo to i do a +a+X[j] A[i] -- a/(1+1) return array A Algorithm 1.14: Algorithm prefixAverages1. Algorithm prefixAverages2(x): Input: An n-clement array X of numbers. Output: An n-element array A of numbers such that A[ij is the average of elements XO),..., X[1. Let A be an array of n numbers. S+0 for i 0 to 1-1 do 5+5+X[] Ai -- 5/(i+1) return array A Algorithm 1.15: Algorithm prefixAverages2. Algorithm prefixAveragesi (x): Input: An n-element array X of numbers. Output: An n-element array A of numbers such that A[i] is the average of elements X(O).....X[i]. Let A be an array of numbers. for i = 0 to 1-1 do 40 for jo to i do a +a+X[j] A[i] -- a/(1+1) return array A Algorithm 1.14: Algorithm prefixAverages1. Algorithm prefixAverages2(x): Input: An n-clement array X of numbers. Output: An n-element array A of numbers such that A[ij is the average of elements XO),..., X[1. Let A be an array of n numbers. S+0 for i 0 to 1-1 do 5+5+X[] Ai -- 5/(i+1) return array A Algorithm 1.15: Algorithm prefixAverages2

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

How to find if any no. is divisble by 4 or not ?

Answered: 1 week ago

Question

Explain the Pascals Law ?

Answered: 1 week ago

Question

What are the objectives of performance appraisal ?

Answered: 1 week ago

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago