SlideShare a Scribd company logo
1 of 19
Program step: Sum of array- recursive
Statement # Statement n<=0 n>0
1 Algorithm
r_Add(a,n)
0 0
2 { 0 0
3 if (n<=0) then 1 1
4 return 0 1 0
5 else return 0 0
6 r_Add(a,n-1) +
a[n]
0 1+n
7 } 0 0
2 n+2
A.R.Tungar (MGMU)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)

More Related Content

What's hot

Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)Sparsh Singh
 
Linear equations in Two Variable
Linear equations in Two VariableLinear equations in Two Variable
Linear equations in Two VariableAbhinav Somani
 
C2 st lecture 6 handout
C2 st lecture 6 handoutC2 st lecture 6 handout
C2 st lecture 6 handoutfatima d
 
Maths ppt linear equations in two variables
Maths ppt   linear equations in two variablesMaths ppt   linear equations in two variables
Maths ppt linear equations in two variablesgobilladraksharani
 
C2 st lecture 5 handout
C2 st lecture 5 handoutC2 st lecture 5 handout
C2 st lecture 5 handoutfatima d
 
Math20001 dec 2015
Math20001 dec 2015Math20001 dec 2015
Math20001 dec 2015Atef Alnazer
 
C2 st lecture 3 handout
C2 st lecture 3 handoutC2 st lecture 3 handout
C2 st lecture 3 handoutfatima d
 
Lecture 11 systems of nonlinear equations
Lecture 11 systems of nonlinear equationsLecture 11 systems of nonlinear equations
Lecture 11 systems of nonlinear equationsHazel Joy Chong
 
C2 st lecture 4 handout
C2 st lecture 4 handoutC2 st lecture 4 handout
C2 st lecture 4 handoutfatima d
 
INVERSION OF MATRIX BY GAUSS ELIMINATION METHOD
INVERSION OF MATRIX BY GAUSS ELIMINATION METHODINVERSION OF MATRIX BY GAUSS ELIMINATION METHOD
INVERSION OF MATRIX BY GAUSS ELIMINATION METHODreach2arkaELECTRICAL
 
Numerical solution of system of linear equations
Numerical solution of system of linear equationsNumerical solution of system of linear equations
Numerical solution of system of linear equationsreach2arkaELECTRICAL
 
Indices and laws of logarithms
Indices and laws of logarithmsIndices and laws of logarithms
Indices and laws of logarithmsJJkedst
 

What's hot (19)

Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)
 
Linear equations in Two Variable
Linear equations in Two VariableLinear equations in Two Variable
Linear equations in Two Variable
 
10.4
10.410.4
10.4
 
Combined variation
Combined variationCombined variation
Combined variation
 
C2 st lecture 6 handout
C2 st lecture 6 handoutC2 st lecture 6 handout
C2 st lecture 6 handout
 
Maths ppt linear equations in two variables
Maths ppt   linear equations in two variablesMaths ppt   linear equations in two variables
Maths ppt linear equations in two variables
 
Directvariation
DirectvariationDirectvariation
Directvariation
 
C2 st lecture 5 handout
C2 st lecture 5 handoutC2 st lecture 5 handout
C2 st lecture 5 handout
 
Math20001 dec 2015
Math20001 dec 2015Math20001 dec 2015
Math20001 dec 2015
 
MaThHs Proportion
MaThHs ProportionMaThHs Proportion
MaThHs Proportion
 
C2 st lecture 3 handout
C2 st lecture 3 handoutC2 st lecture 3 handout
C2 st lecture 3 handout
 
INTEGRATION
INTEGRATIONINTEGRATION
INTEGRATION
 
Lecture 11 systems of nonlinear equations
Lecture 11 systems of nonlinear equationsLecture 11 systems of nonlinear equations
Lecture 11 systems of nonlinear equations
 
C2 st lecture 4 handout
C2 st lecture 4 handoutC2 st lecture 4 handout
C2 st lecture 4 handout
 
Linear and non linear equation
Linear and non linear equationLinear and non linear equation
Linear and non linear equation
 
INVERSION OF MATRIX BY GAUSS ELIMINATION METHOD
INVERSION OF MATRIX BY GAUSS ELIMINATION METHODINVERSION OF MATRIX BY GAUSS ELIMINATION METHOD
INVERSION OF MATRIX BY GAUSS ELIMINATION METHOD
 
Numerical solution of system of linear equations
Numerical solution of system of linear equationsNumerical solution of system of linear equations
Numerical solution of system of linear equations
 
Indices and laws of logarithms
Indices and laws of logarithmsIndices and laws of logarithms
Indices and laws of logarithms
 
Linear Equations
Linear EquationsLinear Equations
Linear Equations
 

Similar to Recursion & methods of proof in algorithm analysis

class 10 chapter 1- real numbers
class 10 chapter 1- real numbersclass 10 chapter 1- real numbers
class 10 chapter 1- real numberskaran saini
 
Complex numbers And Quadratic Equations
Complex numbers And Quadratic EquationsComplex numbers And Quadratic Equations
Complex numbers And Quadratic EquationsDeepanshu Chowdhary
 
Class-10-Mathematics-Chapter-1-CBSE-NCERT.ppsx
Class-10-Mathematics-Chapter-1-CBSE-NCERT.ppsxClass-10-Mathematics-Chapter-1-CBSE-NCERT.ppsx
Class-10-Mathematics-Chapter-1-CBSE-NCERT.ppsxSoftcare Solution
 
Quadratic equations
Quadratic equationsQuadratic equations
Quadratic equationsRajeevRajeev
 
Analytic Geometry Period 1
Analytic Geometry Period 1Analytic Geometry Period 1
Analytic Geometry Period 1ingroy
 
Real number by G R Ahmed of KVK
Real number by G R Ahmed of KVKReal number by G R Ahmed of KVK
Real number by G R Ahmed of KVKMD. G R Ahmed
 
Gmat quant topic 3 (inequalities + absolute value) solutions
Gmat quant topic 3 (inequalities + absolute value) solutionsGmat quant topic 3 (inequalities + absolute value) solutions
Gmat quant topic 3 (inequalities + absolute value) solutionsRushabh Vora
 
sim-140907230908-phpapp01.pptx
sim-140907230908-phpapp01.pptxsim-140907230908-phpapp01.pptx
sim-140907230908-phpapp01.pptxJeffreyEnriquez10
 
Paso 2 contextualizar y profundizar el conocimiento sobre expresiones algebr...
Paso 2  contextualizar y profundizar el conocimiento sobre expresiones algebr...Paso 2  contextualizar y profundizar el conocimiento sobre expresiones algebr...
Paso 2 contextualizar y profundizar el conocimiento sobre expresiones algebr...Trigogeogebraunad
 

Similar to Recursion & methods of proof in algorithm analysis (20)

Statistical Method In Economics
Statistical Method In EconomicsStatistical Method In Economics
Statistical Method In Economics
 
Ecuaciones lineales 1
Ecuaciones lineales 1Ecuaciones lineales 1
Ecuaciones lineales 1
 
Solving Quadratic Equations by Factoring
Solving Quadratic Equations by FactoringSolving Quadratic Equations by Factoring
Solving Quadratic Equations by Factoring
 
Maths project
Maths projectMaths project
Maths project
 
class 10 chapter 1- real numbers
class 10 chapter 1- real numbersclass 10 chapter 1- real numbers
class 10 chapter 1- real numbers
 
Maths project
Maths projectMaths project
Maths project
 
Maths project
Maths projectMaths project
Maths project
 
Advance algebra
Advance algebraAdvance algebra
Advance algebra
 
Imc2016 day2-solutions
Imc2016 day2-solutionsImc2016 day2-solutions
Imc2016 day2-solutions
 
Complex numbers And Quadratic Equations
Complex numbers And Quadratic EquationsComplex numbers And Quadratic Equations
Complex numbers And Quadratic Equations
 
Class-10-Mathematics-Chapter-1-CBSE-NCERT.ppsx
Class-10-Mathematics-Chapter-1-CBSE-NCERT.ppsxClass-10-Mathematics-Chapter-1-CBSE-NCERT.ppsx
Class-10-Mathematics-Chapter-1-CBSE-NCERT.ppsx
 
Quadratic equations
Quadratic equationsQuadratic equations
Quadratic equations
 
Quadratic equations
Quadratic equationsQuadratic equations
Quadratic equations
 
Em01 ba
Em01 baEm01 ba
Em01 ba
 
Analytic Geometry Period 1
Analytic Geometry Period 1Analytic Geometry Period 1
Analytic Geometry Period 1
 
Shortlist jbmo 2016_v7-1
Shortlist jbmo 2016_v7-1Shortlist jbmo 2016_v7-1
Shortlist jbmo 2016_v7-1
 
Real number by G R Ahmed of KVK
Real number by G R Ahmed of KVKReal number by G R Ahmed of KVK
Real number by G R Ahmed of KVK
 
Gmat quant topic 3 (inequalities + absolute value) solutions
Gmat quant topic 3 (inequalities + absolute value) solutionsGmat quant topic 3 (inequalities + absolute value) solutions
Gmat quant topic 3 (inequalities + absolute value) solutions
 
sim-140907230908-phpapp01.pptx
sim-140907230908-phpapp01.pptxsim-140907230908-phpapp01.pptx
sim-140907230908-phpapp01.pptx
 
Paso 2 contextualizar y profundizar el conocimiento sobre expresiones algebr...
Paso 2  contextualizar y profundizar el conocimiento sobre expresiones algebr...Paso 2  contextualizar y profundizar el conocimiento sobre expresiones algebr...
Paso 2 contextualizar y profundizar el conocimiento sobre expresiones algebr...
 

Recently uploaded

Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 

Recursion & methods of proof in algorithm analysis

  • 1. Program step: Sum of array- recursive Statement # Statement n<=0 n>0 1 Algorithm r_Add(a,n) 0 0 2 { 0 0 3 if (n<=0) then 1 1 4 return 0 1 0 5 else return 0 0 6 r_Add(a,n-1) + a[n] 0 1+n 7 } 0 0 2 n+2 A.R.Tungar (MGMU)
  • 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)