Question: Java Progtramming Task A . Implement the three algorithms in Section 1 . 4 in Zybooks: MaxsubSlow ( Figure 1 . 4 . 2 )

Java Progtramming
Task A. Implement the three algorithms in Section 1.4 in Zybooks:
MaxsubSlow (Figure 1.4.2)
MaxsubFaster (Figure 1.4.3)
MaxsubFastest (Figure 1.4.4)
Note that, for all three algorithms, A must contain both positive and negative numbers.
Note: S is a list of numbers, not a variable. Si denotes the i-th element, which will contain the prefix sum of A[i](i.e. the sum of all elements in A up to A[i]). The first element, S0, is given a value of 0 because prefix sum of A[0] is 0, since A[0] does not exist.
Note: M is a list of numbers, not a variable. Mi denotes the i-th element, which is the prefix maximum for A[i](i.e. the largest subarray of A that can be yielded using only elements up to A[i]). The first element, M0, is given a value of 0 because the prefix maximum of A[0] is 0, since A[0] does not exist.
Task B. For each algorithm , perform experiments with 10 different values for n, and measure the running time (i.e. the number of primitive operations, not the system runtime). Select appropriate n values so the running time is measurable and the change in running time is meaningful. Once you have yielded the runtimes, use the tables below to determine which of the following functions best approximates the running time for each algorithm: n, n2, or n3.
Hint: For each value of n, calculate the ratio between the algorithms running time and the function. As n grows infinitely large, the function whose ratio converges to a nonzero value closest to 1 will be the best approximation.
n T1(n)
MaxsubSlow T1(n)/n T1(n)/(n2) T1(n)/(n3)
ninfinite Predict this:
n T2(n)
MaxsubFaster T2(n)/n T2(n)/(n2) T2(n)/(n3)
ninfinite Predict this:
n T3(n)
MaxsubFastest T3(n)/n T3(n)/(n2) T3(n)/(n3)
ninfinite Predict this:
Based on the experimental data, which of the three functions (n, n2, or n3) is the best estimation of the time complexity T(n) of each algorithm?
Answer:
T1(n)=_______________________.
T2(n)=_______________________.
T3(n)=__________________

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 Programming Questions!