A quiz on recurrences Consider the Scala program below performing pairwise summation. Furthermore, let In the following, def add(arr: Array [Double]): Double = def inner (from: Int, to: Int): Double = if from to then arr (from) else val mid from + (to from) / 2 inner (from, mid) + inner (mid+1, to) inner(0, arr.length-1) val a = Array.fill [Double] (100000) (0.00001) c and d are some positive constants and we denote the length of the argument array arr by n. Which of the following statements are true?

icon
Related questions
Question
A quiz on recurrences
Consider the Scala program below performing pairwise summation. Furthermore, let In the following,
def add(arr: Array [Double]): Double =
def inner (from: Int, to: Int): Double =
if from == to then
arr (from)
else
val mid from + (to from) / 2
inner from, mid) + inner (mid+1, to)
inner(0, arr.length-1)
val a =
Array.fill [Double] (100000) (0.00001)
c and d are some positive constants and we denote the length of the argument array arr by n.
Which of the following statements are true?
The number of elements in the array arr is denoted by n.
a.sum = 1.0
a.sum == 0.9999999999980838
a.sum == 1.0000000000000032
add(a) == 1.0
add (a) == 0.9999999999980838
add (a) == 1.0000000000000032
(log n).
(n).
The running time of the program is captured by the recurrence T(n) = d+T([22])+T([2]) with T(1) = c. Thus the running time is
The running time of the program is captured by the recurrence T(n) = d+T([22]) +T([ 2 ]) with T(1) = c. Thus the running time is
The running time of the program is captured by the recurrence T(n) = d+T([ 22 ]) + T([ 22 ]) with T(1) = c. Thus the running time is 0(2¹).
The running time of the program is captured by the recurrence T(n) = d+T(n − 1) + T(n − 1) with T(1) : = c. Thus the running time is (log n).
The running time of the program is captured by the recurrence T(n) = d+T(n − 1) + T(n − 1) with T(1) = c. Thus the running time is 0(2¹).
The running time of the program is captured by the recurrence T(n) = d+T([2]) with T(1) = c. Thus the running time is (log n).
The running time of the program is captured by the recurrence T(n) = d+T([22]) with T(1) = c. Thus the running time is
(n).
Transcribed Image Text:A quiz on recurrences Consider the Scala program below performing pairwise summation. Furthermore, let In the following, def add(arr: Array [Double]): Double = def inner (from: Int, to: Int): Double = if from == to then arr (from) else val mid from + (to from) / 2 inner from, mid) + inner (mid+1, to) inner(0, arr.length-1) val a = Array.fill [Double] (100000) (0.00001) c and d are some positive constants and we denote the length of the argument array arr by n. Which of the following statements are true? The number of elements in the array arr is denoted by n. a.sum = 1.0 a.sum == 0.9999999999980838 a.sum == 1.0000000000000032 add(a) == 1.0 add (a) == 0.9999999999980838 add (a) == 1.0000000000000032 (log n). (n). The running time of the program is captured by the recurrence T(n) = d+T([22])+T([2]) with T(1) = c. Thus the running time is The running time of the program is captured by the recurrence T(n) = d+T([22]) +T([ 2 ]) with T(1) = c. Thus the running time is The running time of the program is captured by the recurrence T(n) = d+T([ 22 ]) + T([ 22 ]) with T(1) = c. Thus the running time is 0(2¹). The running time of the program is captured by the recurrence T(n) = d+T(n − 1) + T(n − 1) with T(1) : = c. Thus the running time is (log n). The running time of the program is captured by the recurrence T(n) = d+T(n − 1) + T(n − 1) with T(1) = c. Thus the running time is 0(2¹). The running time of the program is captured by the recurrence T(n) = d+T([2]) with T(1) = c. Thus the running time is (log n). The running time of the program is captured by the recurrence T(n) = d+T([22]) with T(1) = c. Thus the running time is (n).
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer