2. Execution of Recursive function: Example of Fact function
return => pop this stack and return value 1 to parent
ans=1
is m==1? Yes
fun (m=1)
else { ans = 2* fun (2-1=1)
is m==1? NO
fun (m=2)
else {ans = 3*fun(3-1=2)
is m==1? NO
fun (m=3)
main() function
int fun(int m)
{ int ans;
if (m==1)
{ ans =1;
return ans;
}
else
{ ans = m* fun(m-1);
return ans;
}
}
A.R.Tungar (MGMU)
3. Execution of Recursive function: Example of Fact function
return => pop this stack and return value 2 to parent
else { ans = 2* 1) => ans =2
is m==1? NO
fun (m=2)
else {ans = 3*fun(3-1=2)
is m==1? NO
fun (m=3)
main() function
int fun(int m)
{ int ans;
if (m==1)
{ ans =1;
return ans;
}
else
{ ans = m* fun(m-1);
return ans;
}
}
A.R.Tungar (MGMU)
4. Execution of Recursive function: Example of Fact function
int fun(int m)
{ int ans;
if (m==1)
{ ans =1;
return ans;
}
else
{ ans = m* fun(m-1);
return ans; ans =6 => sent to main
} else {ans = 3* 2)
} is m==1? NO
fun (m=3)
main() function
A.R.Tungar (MGMU)
5. Execution of Recursive function: Example of Fact function
int fun(int m)
{ int ans;
if (m==1)
{ ans =1;
return ans;
}
else
{ ans = m* fun(m-1);
return ans;
}
}
main() function gets vale as 6
A.R.Tungar (MGMU)
6. Linear Equations and Linear Inequalities
An algebraic equation in which each term is either a constant or a the product of constant and a single
variable that algebraic system is called as linear equation.
linear equation using 2 variables :
• y= m*x +b is the most common linear equation.
• x and y are two variables and m and b are constants
• The set of solutions to this equations forms a straight line
• So called as a linear equation
• The general form of such equations is : Ax + By +C =0 ; A and B ≠ 0 and A is a positive integer
• the graph of this equation is a straight line
A.R.Tungar (MGMU)
7. Solving Linear Equations
Prob 1: Find x where 4x +8 =24
1. Keep x on one side of the equation (subtract 8 from both sides)
2. 4x+8 – 8 = 24 -8
3. 4x = 16
4. Divide both sides by 4
5. 4x/4 = 16/4
6. x=4
7. Check if x =4 is correct or not
8. 4x+8= 4(4) +8 = 16 +8= 24
9. 24 = 24
10. So we say x=4 is correct
A.R.Tungar (MGMU)
8. Solving Linear Equations
Prob 2: Find x where 6x -8 = -20
1. Keep x on one side of the equation (subtract -8 from both sides)
2. 6x – 8 –(-8) = -20 – (-8)
3. 6x = -12
4. Divide both sides by 6
5. 6x/6 = -12/6
6. x= -2
7. Check if x =-2 is correct or not
8. 6x -8 = 6(-2) - 8 = -12 - 8= -20
9. -20 = -20
10. So we say x= -2 is correct
A.R.Tungar (MGMU)
9. Solving Linear Equations
Prob 3 : Find x where 2x + 2y =16
1. Keep x on one side of the equation (subtract 2y from both sides)
2. 2x +2y- 2y = 16 – 2y
3. 2x = 16 – 2y
4. Divide both sides by 2
5. x= 8 - y
6. Check if x = 8-y is correct or not
7. 2x + 2y =16 => 2(8-y) + 2y = 16 – 2y + 2y
8. 16 = 16
9. So we say x= 8-y is correct
A.R.Tungar (MGMU)
10. Solving Linear inequations
Linear inequalities have following properties
Consider 3 real numbers x,y and z
1. From property of transitivity : if x<y and y<z then x<z
2. Addition property : if x<y then x+z < y+z
3. Subtraction property : if x<y then x-z < y-z
4. Multiplication property : This property has two situations
1. Property when number is positive real number then if x<y then x*z < y *z
2. Property when number is negative real number then if x<y then x*z > y *z
A.R.Tungar (MGMU)
11. Solving Linear inequations
Solve the following linear inequality
8x – 8 > 4x + 4
1. Given that 8x – 8 > 4x + 4
2. Add +8 to both sides
3. 8x – 8 + 8 > 4x + 4 +8 // addition property
4. 8x > 4x +12
5. Subtract 4x from both sides
6. 8x – 4x > 4x + 12 -4x // subtraction property
7. 4x > 12
8. Multiply both sides by ¼
9. 4x * ¼ > 12 * ¼ // property 4.1
10. x> 3
A.R.Tungar (MGMU)
12. Solving Linear inequations
Solve the following linear inequality
4(6x +4) -40 > 16(x-6)
1. Given that 4(6x +4) -40 > 16(x-6)
2. Simplify and group similar terms
3. 24x + 16 -40 > 16x -96 = 24x -24 > 16x -96
4. Add 24 to both sides
5. 24x -24 + 24 > 16x -96 + 24 // addition property
6. 24x > 16x - 72
7. Subtract 16x from both sides
8. 24x – 16x > 16x - 72 -16x // subtraction property
9. 8x > -72
10. Multiply both sides by 1/8
11. 8x * 1/8 > -72 * 1/8 // property 4.1
12. x> -9
A.R.Tungar (MGMU)
13. Solving Double inequations
Solve the following linear inequality
-4 < 2(x+3) -4 < 6
1. Given that -4 < 2(x+3) -4 < 6
2. Simplify and group similar terms
3. -4 < 2x + 6 -4 < 6 => -4 < 2x +2 < 6
4. Add -2 to all sides
5. -4 + (-2) < 2x + 2 +(-2) < 6 + (-2) // addition property
6. -6 < 2x < 4
7. Multiply both sides by ½
8. -6 * ½ < 2x * ½ < 4 * ½ // property 4.1
9. -3 < x < 2
A.R.Tungar (MGMU)
14. Proof techniques
1. Proof by Contradiction
2. Direct proof
3. Proof by contraposition
4. Proof by counter example
5. Proof by Method of Induction
A.R.Tungar (MGMU)
15. Proof by Contradiction
Proof by Contradiction
1. Assume your statement to be false.
2. Proceed as for simplification with the assumption
3. Come across a contradiction.
4. State that because of the contradiction, it can't be the case that the statement is false, so it must be
true.
A.R.Tungar (MGMU)
16. Proof by Contradiction
Prove by Contradiction : No integers y and z exist for which 24y + 12z = 1
1. Assume your statement to be false: Assume that there exist y and z such that 24y + 12z =1
2. Proceed as for simplification with the assumption: Divide both sides by 12
3. We get 2y + z = 1/12
4. Come across a contradiction: y and z are integers ( so 2*y is also an integer )
5. From statement (3) when two integers are added result is a real number; which is a contradiction
6. State that because of the contradiction, it can't be the case that the statement is false, so it must be
true.
7. No integers y and z exist for which 24y + 12z = 1
A.R.Tungar (MGMU)
17. Proof by Contradiction
Prove by Contradiction : For all integers n, if n^2 is odd, n i also odd
1. Assume your statement to be false: If n ^ 2 is odd, n is even
2. Proceed as for simplification with the assumption: n is an even number so it can be expressed in
terms of some k as n = 2 * k
3. So n ^ 2 = n * n = (2 * k ) * ( 2 * k)
4. n * n (odd number ) = 2 * (2 * k * k)
5. Come across a contradiction: We have an odd number = 2 ( some integer )
6. State that because of the contradiction, it can't be the case that the statement is false, so it must be
true. Statement (5) can never be true
7. So, For all integers n, if n^2 is odd, n i also odd is proved
A.R.Tungar (MGMU)
18. Direct Proof
Direct Proof
• We use it to prove statements of the form ”if p then q” or ”p implies q” which we can write as
p ⇒ q.
• The method of the proof is to takes an original statement p, which we assume to be true, and use it
to show directly that another statement q is true.
• So a direct proof has the following steps:
1. Assume the statement p is true.
2. Use what we know about p and other facts as necessary to deduce that another statement q
is true, that is show p ⇒ q is true.
A.R.Tungar (MGMU)
19. Direct Proof
Direct Proof
Directly prove that if n is an odd integer then n^2 is also an odd integer.
1. Assume that the given statement is true => n is an odd integer then n^2 is also an odd integer.
2. Let p: n is an odd integer and q: n ^2 is odd integer, We have p => q
3. n is an odd integer=> n can be expressed in terms of some k as n = (2k+1)
4. So n ^ 2 = n * n = ( 2k+1) * (2k +1)
5. = (4k^2 + 4k +1)
6. = 2 ( 2k^2 +2k) +1
7. = 2 (X) +1 = odd number
8. Hence proved that n * n = n^2 is also an odd number
A.R.Tungar (MGMU)