Given the following definition, compute Q(5). Q(n) = {0 if n = 0 Q(n) = {2 if n = 1 Q(n) = {4 if n = 2 Q(n) = {Q(n − 1) + Q(n − 2) + Q(n − 3) if n > 2 Q(5) =?
looks you need the values of Q(3) and Q(4), first
that is not provided or asked in the question
Q(n) = {Q(n − 1) + Q(n − 2) + Q(n − 3) if n = 5, it means Q(5) = Q(4) + Q(3) + Q(2) the value of Q(3) is given, nah how about Q(4) and Q(3) ?
not given, but I just figured it out...the answer is Q(5) = 22
yeah, i got Q(5) = 22
thanks for making me think about it differently
Q(5) = Q(4) + Q(3) + Q(2), to get the values of Q(3) and Q(4), respectively : if n = 3, then Q(3) = Q(2) + Q(1) + Q(0) = 4 + 2 + 0 = 6 and n = 4, then Q(4) = Q(3) + Q(2) + Q(1) = 6 + 4 + 2 = 12 therefore, Q(5) = Q(4) + Q(3) + Q(2), Q(5) = 12 + 6 + 4 = 22 hope that make sense :)
Join our real-time social learning platform and learn together with your friends!