SlideShare a Scribd company logo
5
Most read
6
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

What's hot (20)

PPTX
Algorithm and pseudocode conventions
saranyatdr
 
PDF
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
PPT
Np cooks theorem
Narayana Galla
 
PPTX
Backtracking
subhradeep mitra
 
PPTX
Greedy Algorithm - Knapsack Problem
Madhu Bala
 
PPT
SINGLE-SOURCE SHORTEST PATHS
Md. Shafiuzzaman Hira
 
PPTX
Sparse matrix and its representation data structure
Vardhil Patel
 
PPTX
Knapsack problem using greedy approach
padmeshagrekar
 
PPTX
Divide and conquer 1
Kumar
 
PPTX
N queen problem
Ridhima Chowdhury
 
PDF
I.BEST FIRST SEARCH IN AI
vikas dhakane
 
PPTX
Breadth First Search & Depth First Search
Kevin Jadiya
 
PPTX
Bruteforce algorithm
Rezwan Siam
 
PPTX
8 queens problem using back tracking
Tech_MX
 
PPT
Complexity of Algorithm
Muhammad Muzammal
 
PPTX
Binary Heap Tree, Data Structure
Anand Ingle
 
PPTX
Insertion Sorting
FarihaHabib123
 
PPT
KNOWLEDGE REPRESENTATION ISSUES.ppt
SuneethaChittineni
 
PPT
Divide and conquer
Dr Shashikant Athawale
 
PPTX
15 puzzle problem using branch and bound
Abhishek Singh
 
Algorithm and pseudocode conventions
saranyatdr
 
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
Np cooks theorem
Narayana Galla
 
Backtracking
subhradeep mitra
 
Greedy Algorithm - Knapsack Problem
Madhu Bala
 
SINGLE-SOURCE SHORTEST PATHS
Md. Shafiuzzaman Hira
 
Sparse matrix and its representation data structure
Vardhil Patel
 
Knapsack problem using greedy approach
padmeshagrekar
 
Divide and conquer 1
Kumar
 
N queen problem
Ridhima Chowdhury
 
I.BEST FIRST SEARCH IN AI
vikas dhakane
 
Breadth First Search & Depth First Search
Kevin Jadiya
 
Bruteforce algorithm
Rezwan Siam
 
8 queens problem using back tracking
Tech_MX
 
Complexity of Algorithm
Muhammad Muzammal
 
Binary Heap Tree, Data Structure
Anand Ingle
 
Insertion Sorting
FarihaHabib123
 
KNOWLEDGE REPRESENTATION ISSUES.ppt
SuneethaChittineni
 
Divide and conquer
Dr Shashikant Athawale
 
15 puzzle problem using branch and bound
Abhishek Singh
 

Similar to Sum of subsets problem by backtracking  (20)

PPTX
Chapter-5-Frequency-Distribution Mathematics in the modern World.pptx
castrorobertjr21
 
PPTX
Measures of central tendency
Raj Teotia
 
PPTX
Advance Statistics Learning Topics -Jobelle M Quilana Section 7001-1-1-B.pptx
AgapitoBagumbayan3
 
PPTX
Analysis and interpretation of Assessment.pptx
AeonneFlux
 
PPTX
Arithmetic mean
SoyaMathew1
 
PPT
Unit 3-Greedy Method
DevaKumari Vijay
 
PPTX
Chapter-6-Variance Purposive Communication.pptx
castrorobertjr21
 
PDF
divide and conquer algorithm slides for information and review
HFLEX
 
PPTX
analytical representation of data
Unsa Shakir
 
PPTX
Arithmetic Mean in Business Statistics
muthukrishnaveni anand
 
PPTX
Utilization-of-assessment-data-assessmentinLearning1.pptx
EdeleneGetes
 
PPTX
Airthmetic mean
HimanshuMalhotra47
 
PDF
Measures of central tendency - STATISTICS
indianeducation
 
PPTX
lesson 4 measures of central tendency copy
Nerz Baldres
 
PPTX
MEASURES OF CENTRAL TENDENCY ARITHMETIC MEAN.pptx
yogi7397041626
 
PPTX
Chapter-6-Variance.pptx
RiyanElaine
 
PPTX
Combined mean and Weighted Arithmetic Mean
Mamatha Upadhya
 
PPTX
Class X-STATISTICS- PPT.pptx new new new
kv1rcf
 
PPT
Assessment compiled
Lance Gerard G. Abalos LPT, MA
 
Chapter-5-Frequency-Distribution Mathematics in the modern World.pptx
castrorobertjr21
 
Measures of central tendency
Raj Teotia
 
Advance Statistics Learning Topics -Jobelle M Quilana Section 7001-1-1-B.pptx
AgapitoBagumbayan3
 
Analysis and interpretation of Assessment.pptx
AeonneFlux
 
Arithmetic mean
SoyaMathew1
 
Unit 3-Greedy Method
DevaKumari Vijay
 
Chapter-6-Variance Purposive Communication.pptx
castrorobertjr21
 
divide and conquer algorithm slides for information and review
HFLEX
 
analytical representation of data
Unsa Shakir
 
Arithmetic Mean in Business Statistics
muthukrishnaveni anand
 
Utilization-of-assessment-data-assessmentinLearning1.pptx
EdeleneGetes
 
Airthmetic mean
HimanshuMalhotra47
 
Measures of central tendency - STATISTICS
indianeducation
 
lesson 4 measures of central tendency copy
Nerz Baldres
 
MEASURES OF CENTRAL TENDENCY ARITHMETIC MEAN.pptx
yogi7397041626
 
Chapter-6-Variance.pptx
RiyanElaine
 
Combined mean and Weighted Arithmetic Mean
Mamatha Upadhya
 
Class X-STATISTICS- PPT.pptx new new new
kv1rcf
 
Assessment compiled
Lance Gerard G. Abalos LPT, MA
 
Ad

Recently uploaded (20)

PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Ad

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