Opening the reading…
Opening the reading…
TIME AND SPACE COMPLEXITY / ONLINE JUDGE › TIME AND SPACE COMPLEXITY
This is a scratch drill — your code runs, nothing is graded or recorded. No test cases, no expected output, no verdict.
TASK
Complete the Java program so it processes a = [4, 2, 7, 1] with the same two loop blocks. Print sum = 14, prefixTotal = 37, the observed counts 4 and 10, then state C(n) = n + n(n + 1)/2 and Theta(n^2).
OUTPUT
Samplesum = 14 prefixTotal = 37 sumCount = 4 prefixCount = 10 C(4) = 4 + 4(4 + 1)/2 = 14 Theta(n^2)
What a finished answer prints, from the lesson. Nothing has run yet — press Run and this is replaced by your program’s own output.