Question: 2 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),

 2 Pseudocode, and running time analysis. When perform running time analysis,

2 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 (al1...n]) if n-1 return a[1 mid (1+n)/2 11 Largest(a[1.. .mid]) 12 Largest (a[nid+1. . .n]) if (11>12) return 11 else return 12 (b) Analyze the running time of the following procedure which enleulates the largest one day drop or increase in the price of a certain commodity/stock, giwn by a list of numbers. / a[1] 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 (al1.. ]) largestChange 0 //initialzation for i-1 to n-1 if (abs (a[i+1]-ai]))> lagentChange largestChange abs (ali 1]-ai]) return largestChange

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!