Soln IE2108 T01

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

IE2108

Data Structures & Algorithms


Tutorial no. 1

Tutor: Wang Lipo


elpwang@ntu.edu.sg
T1Q1
Determine whether each of the following sequences is increasing,
decreasing, non-increasing or non-decreasing.

(i) 5, 55, 555, 555, 606, 1001, 2002, 2020, 2020


(non-decreasing)
(ii) 5, -55, -555, -606, -1001, -2020, -2020, -3000
(non-increasing)
(iii) 10, 22, 35, 100, 201, 500, 2000
(increasing)
(iv) 5, 5
(non-increasing and non-decreasing)
T1Q2
Find the value of each expression below without using a calculator.
(i) lg 64
lg 26 = 6
(ii) lg 21000
1000
T1Q3
Compute ⌊x⌋ and ⌈x⌉ for each of the following values of x:
(i) 37.99
37.99 = 37
37.99 = 38
(ii) 10/3
10/3 = 3.333 = 3
10/3 = 3.333 = 4
T1Q4
Determine if the following expression is true or false:
𝑛! = 𝑛 × (𝑛 − 1)!

𝑛! = 𝑛 × 𝑛 − 1 × 𝑛 − 2 × ⋯ × 2 × 1
=𝑛× 𝑛−1 !

True!
T1Q5
𝑛 𝑛
Prove that = .
𝑟 𝑛−𝑟

𝑛 𝑛!
=
𝑟 𝑟! 𝑛 − 𝑟 !
𝑛!
=
𝑛 − 𝑟 ! 𝑟!
𝑛!
=
𝑛−𝑟 ! 𝑛− 𝑛−𝑟 !
𝑛
=
𝑛−𝑟

Note: To prove an equation, we may work from the LHS to the RHS, or
from the RHS to the LHS, or from both sides towards a middle ground.
T1Q5 Alternative Proof
𝑛 𝑛
Prove that = .
𝑟 𝑛−𝑟

𝑛 𝑛!
=
𝑟 𝑟! 𝑛 − 𝑟 !

𝑛 𝑛!
=
𝑛−𝑟 𝑛−𝑟 ! 𝑛− 𝑛−𝑟 !
𝑛!
=
𝑛−𝑟 !𝑟!

𝑛
=
𝑟
T1Q6
If 𝑖 is an integer and 𝑖 ≥ 1, find a formula for 1 + 2 + 22 + ⋯ + 2𝑖−1 .

This is a geometric series. Applying the formula for the geometric sum
results in

2𝑖−1+1 − 1
1 + 2 + 22 + ⋯ + 2𝑖−1 =
𝑖
2−1
=2 −1
Note: In this course, you are required to memorize only two important
formulas, i.e., the arithmetic series and geometric series.
T1Q7 Mathematical Induction: the Idea
𝑛 =𝑘+1
Mathematical induction proves that we can climb as 𝑛=𝑘
high as we like on a ladder, by proving that we can
climb onto the bottom rung (the basis step) and that
from each rung we can climb up to the next one (the
inductive step).

1. Basis step:
Check the conclusion is true for 𝑛 = 1.

2. Inductive step:
Assuming that the conclusion is true for 𝑛 = 𝑘, prove
that the conclusion is true for 𝑛 = 𝑘 + 1

𝑛=1
T1Q7 (i)
Use mathematical induction to prove that each equation is true for every positive
integer 𝑛.
σ𝑛𝑖=1 𝑖 ⋅ (𝑖!) = (𝑛 + 1)! − 1 (equation 1)

Basis step:
When 𝑛 = 1, equation 1 holds, as the LHS and the RHS are both equal to 1.

Inductive step:
Assume that equation 1 is true for 𝑛 = 𝑘, i. e. ,
σ𝑘𝑖=1 𝑖 ⋅ (𝑖!) = (𝑘 + 1)! − 1 (equation 2)
We want to prove that equation 1 is valid for 𝑛 = 𝑘 + 1, i. e.,
σ𝑘+1
𝑖=1 𝑖 ⋅ (𝑖!) = (𝑘 + 2)! − 1 (equation 3)
T1Q7 (i) …

𝑘+1 𝑘

෍ 𝑖 ⋅ (𝑖!) = ෍ 𝑖 ⋅ (𝑖!) + 𝑘 + 1 ⋅ 𝑘 + 1 !
𝑖=1 𝑖=1
Substituting equation 2 for the 1st term in the RHS:
σ𝑘+1
𝑖=1 𝑖 ⋅ (𝑖!) = 𝑘 + 1 ! − 1 + 𝑘 + 1 ⋅ 𝑘 + 1 !
= 1+ 𝑘+1 ⋅ 𝑘+1 ! −1
= 𝑘+2 ⋅ 𝑘+1 !−1
= 𝑘+2 !−1
Equation 3 is obtained.
T1Q7 (ii)
Use mathematical induction to prove that the following is true for
every positive integer 𝑛.
1 + 𝑥 𝑛 ≥ 1 + 𝑛𝑥, where 𝑥 ≥ −1 (expression 1)
Basis step:
When 𝑛 = 1, 1 + 𝑥 1 = 1 + 𝑥. Hence, expression 1 is true.
Inductive step:
Assume that the expression is true for 𝑛 = 𝑘, i. e. ,
1 + 𝑥 𝑘 ≥ 1 + 𝑘𝑥, where 𝑥 ≥ −1 (expression 2)
We want to prove that expression 1 is valid for 𝑛 = 𝑘 + 1, i. e.,
1 + 𝑥 𝑘+1 ≥ 1 + (𝑘 + 1)𝑥, where 𝑥 ≥ −1 (expression 3)
T1Q7 (ii) …
1+𝑥 𝑘+1 = 1+𝑥 𝑘 × 1+𝑥

Note that 1 + 𝑥 ≥ 0 when 𝑥 ≥ −1. Substituting expression 2 into


the RHS of the above, we obtain

𝑘+1
1+𝑥 ≥ 1 + 𝑘𝑥 × 1 + 𝑥
= 1 + 𝑘𝑥 + 𝑥 + 𝑘𝑥 2
≥1+ 𝑘+1 𝑥
Expression 3 is proven.

You might also like