12/06/2024, 00:56 Assignment 2 CS2214 - no answer i need the unlcok for astronomy lol
Assignment 2 CS2214
Question 1.
i)
Explicit:
(n(n+1)(2n+1))/6 + (5n(n+1))/2 + 2n
Recursive:
f(n) = 2 | n = 0
f(n) = f(n-1) + 4+2n | n >= 1
ii)
f(0) = 1
f(1) = 1
f(2) = 2(f(0)+f(1)+f(0))
f(3) = 2(f(1)+f(2)+f(1))
f(4) = 2f(f(2)+f(3)+f(2))
f(n) = 2(f(n-2)+f(n-1)+f(n-2))
Question 2.
𝑛
i)
∑ 𝑖 =
3 𝑛 (𝑛+1)
2 2
4
𝑖=1
1 + 2 +... + 𝑛 =
3 3 3 𝑛 (𝑛+1)
2 2
4
1 =
3
Base case: for n = 1 the sum of i^3 from 1 to n that is just 1 equals (1^2(1+1)^2)/4 = 1
1 (1+1)
2 2
4
1=
(2)
2
4
1=
4
4
1= 1
0 + 1 + 2 +... + 𝑘 =
3 3 3 3
Induction Step: assume for arbitrary k we have
𝑘 (𝑘+1)
2 2
4
IH
0 + 1 + 2 +... + 𝑘 + (𝑘 + 1) =
3 3 3 3 3 (𝑘+1) ((𝑘+1)+1)
2 2
4
about:blank 1/4
Assignment 2 CS2214
Question 1.
i)
Explicit:
(n(n+1)(2n+1))/6 + (5n(n+1))/2 + 2n
Recursive:
f(n) = 2 | n = 0
f(n) = f(n-1) + 4+2n | n >= 1
ii)
f(0) = 1
f(1) = 1
f(2) = 2(f(0)+f(1)+f(0))
f(3) = 2(f(1)+f(2)+f(1))
f(4) = 2f(f(2)+f(3)+f(2))
f(n) = 2(f(n-2)+f(n-1)+f(n-2))
Question 2.
𝑛
i)
∑ 𝑖 =
3 𝑛 (𝑛+1)
2 2
4
𝑖=1
1 + 2 +... + 𝑛 =
3 3 3 𝑛 (𝑛+1)
2 2
4
1 =
3
Base case: for n = 1 the sum of i^3 from 1 to n that is just 1 equals (1^2(1+1)^2)/4 = 1
1 (1+1)
2 2
4
1=
(2)
2
4
1=
4
4
1= 1
0 + 1 + 2 +... + 𝑘 =
3 3 3 3
Induction Step: assume for arbitrary k we have
𝑘 (𝑘+1)
2 2
4
IH
0 + 1 + 2 +... + 𝑘 + (𝑘 + 1) =
3 3 3 3 3 (𝑘+1) ((𝑘+1)+1)
2 2
4
about:blank 1/4