CIS 360 Lab #2: Implementing and Analyze Algorithms
Name ____________________________ ID ________________________
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)
•
Task B. For each algorithm , perform experiment with 10 different n values and measure the
running time. Select appropriate n values so the running time is measurable and the change in
running time is meaningful. Fill the table below.
n T1(n)
MaxsubSlow
T1(n)/n T1(n)/(n^2) T1(n)/(n^3)
nàinfinite Predict this:
n T2(n)
MaxsubFaster
T2(n)/n T2(n)/(n^2) T2(n)/(n^3)
nàinfinite Predict this:
n T3(n)
MaxsubFastest
T3(n)/n T3(n)/(n^2) T3(n)/(n^3)
nàinfinite Predict this:
Based on the experimental data, What function is the best estimation of the time complexity T(n)
of each algorithm?
Answer:
T1(n) = _______________________.
T2(n) = _______________________.
T3(n) = _______________________.
Does your answer above match the analysis result in Section 1.4? Yes / No __________
If No, what would be the reasons?
_______________________________________________________________________________