Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Pseudocode, and running time analysis. When perform running time analysis, first express the number of computer steps, T(n), in terms of n (input size),

image text in transcribed

1. Pseudocode, and running time analysis. When perform running time analysis, first express the number of computer steps, T(n), in terms of n (input size), and then use big-o notations (the three of them) to simplify the expression. (a) analyze the running time of the following pseudocode Largest (a1..n]) ifn 1 return a[1] mid (1+n)/2 11 = Largest(a( 1 mid]) 12- Largest (a[mid+1..n]) if (11>12) return 11 else return 12 (b) Analyze the running time of the following procedure which calculates the largest one day drop or increase in the price of a certain commodity/stock, given by a list of numbers. /* a1] is the price on first day, a[2] is the price on day 2, return the largest increase/drop (from one day to the next) in the data */ LargestOneDayDifference (a.n]) largestChange 0 /initialzation for i-1 to n-1 if (abs(a[i+1-ai>lagestChange largestChange = abs (a[i+1 ]-a[i]) return largestChange (c) Analyze the running time of the following pseudocode which has nested loops: some func (data [1...n]) create an array/list of len n-4, sum for i-1 to n-4 sum[i] = 0 for j-i to i+4 sum[i] = sum[i1+ data[j] largest = sum[i] for i=1 to n-4 if (sum i largest) largest- sum[i]

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_2

Step: 3

blur-text-image_3

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

What are some of the hiring standards to avoid?

Answered: 1 week ago

Question

=+ f. instituting laws against driving while intoxicated

Answered: 1 week ago

Question

=+ Why have these changes occurred?

Answered: 1 week ago