SlideShare a Scribd company logo
4
Most read
5
Most read
9
Most read
Sum of Subsets Problem
By
Backtracking
Presentation by
Hasanain ALshadoodee
Backtracking
Learning Outcomes
At the end of session viewers will be to
 Apply backtracking approach to solve sum of subsets problem
Presentation by_Hasanain ALshadoodee
2
Presentation by_Hasanain ALshadoodee
3
Introduction
 We are given n distinct positive numbers (weights)
 The objective is to find all combination of weights whose
sum is equal to given weights m
 State space tree is generated for all the possibilities of
the subsets
 Generate the tree by keeping weight <= m
Example
Consider the example given below
n= 4
W{1:4}= {5,10,15,20}
m= 25
Find the sum of subset equal to m
Presentation by_Hasanain ALshadoodee
4
Example
n= 4
W{1:4}= {5,10,15,20}
m= 25
Presentation by_Hasanain ALshadoodee
5
0,50
5,45
15,35
30,20 15,20
35, 0 15, 0
5,35
5,20
25, 0
X1=1
X2=1
X3=1
X2=0
X3=0
X4=1 X4=0
X3=0
X4=1
Solution
X1,x2,x3,x4={1,0,0,1}
First node two value one the
value is the subset=0
And second value
Summation of all value
=5+10+15+20
=50
0+5=5 50-5=45
45-10=35
5+10=15
Think and Write
Presentation by_Hasanain ALshadoodee
6
Find another subset which is equal to m where
n= 4
W{1:4}= {5,10,15,20}
m= 25
0,50
0,45
10,35
25,20
25, 0
Solution
X1,x2,x3,x4={0,1,1,0}
X1=0
X2=1
X3=1
X4=0
Without increase 50-5=45
45-10=35
0+10=10
subset sum problem using
backtracking python Code Answer
Presentation by_Hasanain ALshadoodee
7
Another Example
Presentation by_Hasanain ALshadoodee
8
the problem is to find a subset of a given set
S={S1,S2,……,Sn} of n positive integers whose sum is
equal to a given positive integer “ d “.
S1<=S2<=…….<=Sn
Presentation by_Hasanain ALshadoodee
9
Ex.. For S={1,3,4,5} 2d=8
SLo={1,3,4}=8 SLo={3,5}=8
0
1
4
8 4
1
5 1
0
3
7 3
0
4 0
6 1 8
State Space Tree
X=3
X=1
X=4
X=5
3
Presentation by_HasanainALshadoodee 10

More Related Content

PPTX
sum of subset problem using Backtracking
PPTX
Sum of subset problem.pptx
PPT
Backtracking Algorithm.ppt
PPTX
Operating Systems: Device Management
PDF
Design and analysis of algorithms
PPT
pushdown automata
PPTX
07. Virtual Functions
PPTX
Stock Market Prediction using Machine Learning
sum of subset problem using Backtracking
Sum of subset problem.pptx
Backtracking Algorithm.ppt
Operating Systems: Device Management
Design and analysis of algorithms
pushdown automata
07. Virtual Functions
Stock Market Prediction using Machine Learning

What's hot (20)

PPTX
The n Queen Problem
DOC
Branch and bound
PPTX
Forms of learning in ai
PPTX
Heuristics Search Techniques in AI
PDF
Unit3:Informed and Uninformed search
PDF
I. AO* SEARCH ALGORITHM
PPT
Np cooks theorem
PPTX
Daa unit 1
PPT
AI Lecture 3 (solving problems by searching)
PPTX
daa-unit-3-greedy method
PPT
Conceptual dependency
PDF
I.BEST FIRST SEARCH IN AI
PPTX
Graph coloring using backtracking
PPT
Error Detection And Correction
PPT
Chapter 4 data link layer
PPTX
Recurrent Neural Networks (RNNs)
PPTX
AI: AI & Problem Solving
PPTX
Performance analysis(Time & Space Complexity)
PDF
Time and Space Complexity
The n Queen Problem
Branch and bound
Forms of learning in ai
Heuristics Search Techniques in AI
Unit3:Informed and Uninformed search
I. AO* SEARCH ALGORITHM
Np cooks theorem
Daa unit 1
AI Lecture 3 (solving problems by searching)
daa-unit-3-greedy method
Conceptual dependency
I.BEST FIRST SEARCH IN AI
Graph coloring using backtracking
Error Detection And Correction
Chapter 4 data link layer
Recurrent Neural Networks (RNNs)
AI: AI & Problem Solving
Performance analysis(Time & Space Complexity)
Time and Space Complexity
Ad

Similar to Sum of subsets problem by backtracking  (20)

PPTX
Chapter-5-Frequency-Distribution Mathematics in the modern World.pptx
PPTX
Measures of central tendency
PPTX
Advance Statistics Learning Topics -Jobelle M Quilana Section 7001-1-1-B.pptx
PPTX
Analysis and interpretation of Assessment.pptx
PPTX
Arithmetic mean
PPT
Unit 3-Greedy Method
PPTX
Chapter-6-Variance Purposive Communication.pptx
PDF
divide and conquer algorithm slides for information and review
PPTX
analytical representation of data
PPTX
Arithmetic Mean in Business Statistics
PPTX
Utilization-of-assessment-data-assessmentinLearning1.pptx
PPTX
Airthmetic mean
PDF
Measures of central tendency - STATISTICS
PPTX
lesson 4 measures of central tendency copy
PPTX
MEASURES OF CENTRAL TENDENCY ARITHMETIC MEAN.pptx
PPTX
Chapter-6-Variance.pptx
PPTX
Combined mean and Weighted Arithmetic Mean
PPTX
Class X-STATISTICS- PPT.pptx new new new
PPT
Assessment compiled
Chapter-5-Frequency-Distribution Mathematics in the modern World.pptx
Measures of central tendency
Advance Statistics Learning Topics -Jobelle M Quilana Section 7001-1-1-B.pptx
Analysis and interpretation of Assessment.pptx
Arithmetic mean
Unit 3-Greedy Method
Chapter-6-Variance Purposive Communication.pptx
divide and conquer algorithm slides for information and review
analytical representation of data
Arithmetic Mean in Business Statistics
Utilization-of-assessment-data-assessmentinLearning1.pptx
Airthmetic mean
Measures of central tendency - STATISTICS
lesson 4 measures of central tendency copy
MEASURES OF CENTRAL TENDENCY ARITHMETIC MEAN.pptx
Chapter-6-Variance.pptx
Combined mean and Weighted Arithmetic Mean
Class X-STATISTICS- PPT.pptx new new new
Assessment compiled
Ad

Recently uploaded (20)

DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PPTX
Virtual and Augmented Reality in Current Scenario
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
advance database management system book.pdf
PDF
Indian roads congress 037 - 2012 Flexible pavement
PDF
1_English_Language_Set_2.pdf probationary
PDF
Hazard Identification & Risk Assessment .pdf
PDF
Computing-Curriculum for Schools in Ghana
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
AI-driven educational solutions for real-life interventions in the Philippine...
Virtual and Augmented Reality in Current Scenario
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
FORM 1 BIOLOGY MIND MAPS and their schemes
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
Paper A Mock Exam 9_ Attempt review.pdf.
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Introduction to pro and eukaryotes and differences.pptx
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
202450812 BayCHI UCSC-SV 20250812 v17.pptx
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
A powerpoint presentation on the Revised K-10 Science Shaping Paper
advance database management system book.pdf
Indian roads congress 037 - 2012 Flexible pavement
1_English_Language_Set_2.pdf probationary
Hazard Identification & Risk Assessment .pdf
Computing-Curriculum for Schools in Ghana

Sum of subsets problem by backtracking 

  • 1. Sum of Subsets Problem By Backtracking Presentation by Hasanain ALshadoodee Backtracking
  • 2. Learning Outcomes At the end of session viewers will be to  Apply backtracking approach to solve sum of subsets problem Presentation by_Hasanain ALshadoodee 2
  • 3. Presentation by_Hasanain ALshadoodee 3 Introduction  We are given n distinct positive numbers (weights)  The objective is to find all combination of weights whose sum is equal to given weights m  State space tree is generated for all the possibilities of the subsets  Generate the tree by keeping weight <= m
  • 4. Example Consider the example given below n= 4 W{1:4}= {5,10,15,20} m= 25 Find the sum of subset equal to m Presentation by_Hasanain ALshadoodee 4
  • 5. Example n= 4 W{1:4}= {5,10,15,20} m= 25 Presentation by_Hasanain ALshadoodee 5 0,50 5,45 15,35 30,20 15,20 35, 0 15, 0 5,35 5,20 25, 0 X1=1 X2=1 X3=1 X2=0 X3=0 X4=1 X4=0 X3=0 X4=1 Solution X1,x2,x3,x4={1,0,0,1} First node two value one the value is the subset=0 And second value Summation of all value =5+10+15+20 =50 0+5=5 50-5=45 45-10=35 5+10=15
  • 6. Think and Write Presentation by_Hasanain ALshadoodee 6 Find another subset which is equal to m where n= 4 W{1:4}= {5,10,15,20} m= 25 0,50 0,45 10,35 25,20 25, 0 Solution X1,x2,x3,x4={0,1,1,0} X1=0 X2=1 X3=1 X4=0 Without increase 50-5=45 45-10=35 0+10=10
  • 7. subset sum problem using backtracking python Code Answer Presentation by_Hasanain ALshadoodee 7
  • 8. Another Example Presentation by_Hasanain ALshadoodee 8 the problem is to find a subset of a given set S={S1,S2,……,Sn} of n positive integers whose sum is equal to a given positive integer “ d “. S1<=S2<=…….<=Sn
  • 9. Presentation by_Hasanain ALshadoodee 9 Ex.. For S={1,3,4,5} 2d=8 SLo={1,3,4}=8 SLo={3,5}=8 0 1 4 8 4 1 5 1 0 3 7 3 0 4 0 6 1 8 State Space Tree X=3 X=1 X=4 X=5 3