Submit Search
Upload
Longest common sub sequence & 0/1 Knapsack
•
Download as PPTX, PDF
•
0 likes
•
23 views
A
Asif Shahriar
Follow
Simulation of Longest common sub sequence & 0/1 Knapsack Algorithm
Read less
Read more
Education
Slideshow view
Report
Share
Slideshow view
Report
Share
1 of 25
Download now
Recommended
Knapsack problem dynamicprogramming
Knapsack problem dynamicprogramming
rowntu
01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming
Fenil Shah
A Course in Fuzzy Systems and Control Matlab Chapter two
A Course in Fuzzy Systems and Control Matlab Chapter two
Chung Hua Universit
16 dot product angles-projection
16 dot product angles-projection
math260
16 dot product angles-projection
16 dot product angles-projection
math260
267 3 dot product-angles-projection-n
267 3 dot product-angles-projection-n
math260
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)
IJERD Editor
Data Types
Data Types
Masters Academy
Recommended
Knapsack problem dynamicprogramming
Knapsack problem dynamicprogramming
rowntu
01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming
Fenil Shah
A Course in Fuzzy Systems and Control Matlab Chapter two
A Course in Fuzzy Systems and Control Matlab Chapter two
Chung Hua Universit
16 dot product angles-projection
16 dot product angles-projection
math260
16 dot product angles-projection
16 dot product angles-projection
math260
267 3 dot product-angles-projection-n
267 3 dot product-angles-projection-n
math260
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)
IJERD Editor
Data Types
Data Types
Masters Academy
Datamining R 1st
Datamining R 1st
sesejun
PRE: Datamining 2nd R
PRE: Datamining 2nd R
sesejun
Datamining r 1st
Datamining r 1st
sesejun
Sol3
Sol3
Esteban Parra
Presentation4
Presentation4
Jorge707r
Algebra 1 Item No 22
Algebra 1 Item No 22
Lappy Doods
ゲーム理論BASIC 演習6 -仁を求める-
ゲーム理論BASIC 演習6 -仁を求める-
ssusere0a682
Surds & indices in business mathematics
Surds & indices in business mathematics
Dr. Trilok Kumar Jain
9 chap
9 chap
Anantha Bellary
All about life and death volume 1 - a basic dictionary of life and death - ...
All about life and death volume 1 - a basic dictionary of life and death - ...
Eases Pe'Ple
The chain rule
The chain rule
Shaun Wilson
Getting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n Monads
Richard Minerich
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
ssusere0a682
On Bernstein Polynomials
On Bernstein Polynomials
IOSR Journals
Integrales solucionario
Integrales solucionario
Gualberto Lopéz Durán
Kisi2+met num
Kisi2+met num
Alvin Setiawan
P9 quotient
P9 quotient
walshbarbaram
DynProg_Knapsack.ppt
DynProg_Knapsack.ppt
Ruchika Sinha
Knapsack problem
Knapsack problem
Vikas Sharma
Knapsack problem using dynamic programming
Knapsack problem using dynamic programming
khush_boo31
lecture 25
lecture 25
sajinsc
Knapsack problem and Memory Function
Knapsack problem and Memory Function
Barani Tharan
More Related Content
What's hot
Datamining R 1st
Datamining R 1st
sesejun
PRE: Datamining 2nd R
PRE: Datamining 2nd R
sesejun
Datamining r 1st
Datamining r 1st
sesejun
Sol3
Sol3
Esteban Parra
Presentation4
Presentation4
Jorge707r
Algebra 1 Item No 22
Algebra 1 Item No 22
Lappy Doods
ゲーム理論BASIC 演習6 -仁を求める-
ゲーム理論BASIC 演習6 -仁を求める-
ssusere0a682
Surds & indices in business mathematics
Surds & indices in business mathematics
Dr. Trilok Kumar Jain
9 chap
9 chap
Anantha Bellary
All about life and death volume 1 - a basic dictionary of life and death - ...
All about life and death volume 1 - a basic dictionary of life and death - ...
Eases Pe'Ple
The chain rule
The chain rule
Shaun Wilson
Getting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n Monads
Richard Minerich
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
ssusere0a682
On Bernstein Polynomials
On Bernstein Polynomials
IOSR Journals
Integrales solucionario
Integrales solucionario
Gualberto Lopéz Durán
Kisi2+met num
Kisi2+met num
Alvin Setiawan
P9 quotient
P9 quotient
walshbarbaram
What's hot
(17)
Datamining R 1st
Datamining R 1st
PRE: Datamining 2nd R
PRE: Datamining 2nd R
Datamining r 1st
Datamining r 1st
Sol3
Sol3
Presentation4
Presentation4
Algebra 1 Item No 22
Algebra 1 Item No 22
ゲーム理論BASIC 演習6 -仁を求める-
ゲーム理論BASIC 演習6 -仁を求める-
Surds & indices in business mathematics
Surds & indices in business mathematics
9 chap
9 chap
All about life and death volume 1 - a basic dictionary of life and death - ...
All about life and death volume 1 - a basic dictionary of life and death - ...
The chain rule
The chain rule
Getting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n Monads
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
On Bernstein Polynomials
On Bernstein Polynomials
Integrales solucionario
Integrales solucionario
Kisi2+met num
Kisi2+met num
P9 quotient
P9 quotient
Similar to Longest common sub sequence & 0/1 Knapsack
DynProg_Knapsack.ppt
DynProg_Knapsack.ppt
Ruchika Sinha
Knapsack problem
Knapsack problem
Vikas Sharma
Knapsack problem using dynamic programming
Knapsack problem using dynamic programming
khush_boo31
lecture 25
lecture 25
sajinsc
Knapsack problem and Memory Function
Knapsack problem and Memory Function
Barani Tharan
0-1 knapsack.ppt
0-1 knapsack.ppt
AyushJaiswal513854
3 dot product angles-projection
3 dot product angles-projection
math267
13 - 06 Feb - Dynamic Programming
13 - 06 Feb - Dynamic Programming
Neeldhara Misra
Pascal’s Triangle
Pascal’s Triangle
Clayton Rainsberg
Similar to Longest common sub sequence & 0/1 Knapsack
(9)
DynProg_Knapsack.ppt
DynProg_Knapsack.ppt
Knapsack problem
Knapsack problem
Knapsack problem using dynamic programming
Knapsack problem using dynamic programming
lecture 25
lecture 25
Knapsack problem and Memory Function
Knapsack problem and Memory Function
0-1 knapsack.ppt
0-1 knapsack.ppt
3 dot product angles-projection
3 dot product angles-projection
13 - 06 Feb - Dynamic Programming
13 - 06 Feb - Dynamic Programming
Pascal’s Triangle
Pascal’s Triangle
Recently uploaded
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
National Information Standards Organization (NISO)
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
National Information Standards Organization (NISO)
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
sanyamsingh5019
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
FatimaKhan178732
mini mental status format.docx
mini mental status format.docx
PoojaSen20
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
RAM LAL ANAND COLLEGE, DELHI UNIVERSITY.
microwave assisted reaction. General introduction
microwave assisted reaction. General introduction
Maksud Ahmed
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
Chameera Dedduwage
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
VS Mahajan Coaching Centre
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
GaneshChakor2
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
chloefrazer622
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
EduSkills OECD
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
JemimahLaneBuaron
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
iammrhaywood
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
Association for Project Management
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
TechSoup
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
Steve Thomason
Recently uploaded
(20)
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
mini mental status format.docx
mini mental status format.docx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
microwave assisted reaction. General introduction
microwave assisted reaction. General introduction
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
Longest common sub sequence & 0/1 Knapsack
1.
Longest Common Subsequence By Asif
Shahriar ID: 171-15-8617
2.
#include<stdio.h> int main() { int i=0,j=0,x[100],y[100],c[100][100],mx,ny,k; printf("Enter
the first(x) string lenght: "); scanf("%d",&mx); printf("Enter the first(x) string : "); for(k=1;k<=mx;k++) { scanf("%d",&x[k]); } printf("Enter the second(y) string lenght: "); scanf("%d",&ny); printf("Enter the second(y) string : "); for(k=1;k<=ny;k++) { scanf("%d",&y[k]); } for(i=1;i<=mx;i++) { c[i][0]=0; c[0][i]=0; }
3.
#include<stdio.h> int main() { int i=0,j=0,x[100],y[100],c[100][100],mx,ny,k; printf("Enter
the first(x) string lenght: "); scanf("%d",&mx); printf("Enter the first(x) string : "); for(k=1;k<=mx;k++) { scanf("%d",&x[k]); } printf("Enter the second(y) string lenght: "); scanf("%d",&ny); printf("Enter the second(y) string : "); for(k=1;k<=ny;k++) { scanf("%d",&y[k]); } for(i=1;i<=mx;i++) { c[i][0]=0; c[0][i]=0; }
4.
#include<stdio.h> int main() { int i=0,j=0,x[100],y[100],c[100][100],mx,ny,k; printf("Enter
the first(x) string lenght: "); scanf("%d",&mx); printf("Enter the first(x) string : "); for(k=1;k<=mx;k++) { scanf("%d",&x[k]); } printf("Enter the second(y) string lenght: "); scanf("%d",&ny); printf("Enter the second(y) string : "); for(k=1;k<=ny;k++) { scanf("%d",&y[k]); } for(i=1;i<=mx;i++) { c[i][0]=0; c[0][i]=0; }
5.
#include<stdio.h> int main() { int i=0,j=0,x[100],y[100],c[100][100],mx,ny,k; printf("Enter
the first(x) string lenght: "); scanf("%d",&mx); printf("Enter the first(x) string : "); for(k=1;k<=mx;k++) { scanf("%d",&x[k]); } printf("Enter the second(y) string lenght: "); scanf("%d",&ny); printf("Enter the second(y) string : "); for(k=1;k<=ny;k++) { scanf("%d",&y[k]); } for(i=1;i<=mx;i++) { c[i][0]=0; c[0][i]=0; }
6.
for(i=1;i<=mx;i++) { for(j=1;j<=ny;j++) { if(x[i]==y[j]) { c[i][j]=c[i-1][j-1]+1; } else if(c[i-1][j]>=c[i][j-1]) { c[i][j]=c[i-1][j]; } else { c[i][j]=c[i][j-1]; } } } i=1 j=1
7.
for(i=1;i<=mx;i++) { for(j=1;j<=ny;j++) { if(x[i]==y[j]) { c[i][j]=c[i-1][j-1]+1; } else if(c[i-1][j]>=c[i][j-1]) { c[i][j]=c[i-1][j]; } else { c[i][j]=c[i][j-1]; } } } 0 i=1 j=1
8.
for(i=1;i<=mx;i++) { for(j=1;j<=ny;j++) { if(x[i]==y[j]) { c[i][j]=c[i-1][j-1]+1; } else if(c[i-1][j]>=c[i][j-1]) { c[i][j]=c[i-1][j]; } else { c[i][j]=c[i][j-1]; } } } 0 0 i=1
j=2
9.
for(i=1;i<=mx;i++) { for(j=1;j<=ny;j++) { if(x[i]==y[j]) { c[i][j]=c[i-1][j-1]+1; } else if(c[i-1][j]>=c[i][j-1]) { c[i][j]=c[i-1][j]; } else { c[i][j]=c[i][j-1]; } } } 0 0
0 i=1 j=3
10.
for(i=1;i<=mx;i++) { for(j=1;j<=ny;j++) { if(x[i]==y[j]) { c[i][j]=c[i-1][j-1]+1; } else if(c[i-1][j]>=c[i][j-1]) { c[i][j]=c[i-1][j]; } else { c[i][j]=c[i][j-1]; } } } 0 0
0 1 i=1 j=4
11.
for(i=1;i<=mx;i++) { for(j=1;j<=ny;j++) { if(x[i]==y[j]) { c[i][j]=c[i-1][j-1]+1; } else if(c[i-1][j]>=c[i][j-1]) { c[i][j]=c[i-1][j]; } else { c[i][j]=c[i][j-1]; } } } 0 0
0 1 1 i=1 j=5
12.
for(i=1;i<=mx;i++) { for(j=1;j<=ny;j++) { if(x[i]==y[j]) { c[i][j]=c[i-1][j-1]+1; } else if(c[i-1][j]>=c[i][j-1]) { c[i][j]=c[i-1][j]; } else { c[i][j]=c[i][j-1]; } } } 0 0
0 1 1 1 i=2 j=1
13.
for(i=1;i<=mx;i++) { for(j=1;j<=ny;j++) { if(x[i]==y[j]) { c[i][j]=c[i-1][j-1]+1; } else if(c[i-1][j]>=c[i][j-1]) { c[i][j]=c[i-1][j]; } else { c[i][j]=c[i][j-1]; } } } 0 0
0 1 1 1 1 1 1 2 1 1 2 2 2 1 1 2 2 3
14.
printf("The lenght of
LCS is %d",c[mx][ny]); 0 0 0 1 1 1 1 1 1 2 1 1 2 2 2 1 1 2 2 3
15.
0/1 Knapsack By Asif Shahriar ID:
171-15-8617
16.
0 1 2
3 4 5 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 weight I t e m Item 1 2 3 4 Weight 2 3 4 5 Value 3 4 5 6 i = 1 w = 1 wi = 2 bi = 3 w-wi = -1 if wi<=w and b1 + V[i-1, w-wi] > V[i-1,w] V[i,w] = b1 + V[i-1,w-wi] else V[i,w] = V[ i-1,w]
17.
0 1 2
3 4 5 0 0 0 0 0 0 0 0 3 0 0 0 0 1 2 3 4 weight I t e m Item 1 2 3 4 Weight 2 3 4 5 Value 3 4 5 6 i = 1 w = 1 wi = 2 bi = 3 w-wi = -1 if wi<=w and b1 + V[i-1, w-wi] > V[i-1,w] V[i,w] = b1 + V[i-1,w-wi] else V[i,w] = V[ i-1,w]
18.
0 1 2
3 4 5 0 0 0 0 0 0 0 0 3 0 0 0 0 1 2 3 4 weight I t e m Item 1 2 3 4 Weight 2 3 4 5 Value 3 4 5 6 i = 1 w = 2 wi = 2 bi = 3 w-wi = 0 if wi<=w and b1 + V[i-1, w-wi] > V[i-1,w] V[i,w] = b1 + V[i-1,w-wi] else V[i,w] = V[ i-1,w]
19.
0 1 2
3 4 5 0 0 0 0 0 0 0 0 3 3 3 3 0 0 0 0 1 2 3 4 weight I t e m Item 1 2 3 4 Weight 2 3 4 5 Value 3 4 5 6 i = 1 w = 2,3,4,5 wi = 2 bi = 3 w-wi = 0 if wi<=w and b1 + V[i-1, w-wi] > V[i-1,w] V[i,w] = b1 + V[i-1,w-wi] else V[i,w] = V[ i-1,w]
20.
0 1 2
3 4 5 0 0 0 0 0 0 0 0 3 3 3 3 0 0 0 0 0 1 2 3 4 weight I t e m Item 1 2 3 4 Weight 2 3 4 5 Value 3 4 5 6 i = 2 w = 1 wi = 3 bi = 4 w-wi = -2 if wi<=w and b1 + V[i-1, w-wi] > V[i-1,w] V[i,w] = b1 + V[i-1,w-wi] else V[i,w] = V[ i-1,w]
21.
0 1 2
3 4 5 0 0 0 0 0 0 0 0 3 3 3 3 0 0 3 0 0 0 1 2 3 4 weight I t e m Item 1 2 3 4 Weight 2 3 4 5 Value 3 4 5 6 i = 2 w = 2 wi = 3 bi = 4 w-wi = -1 if wi<=w and b1 + V[i-1, w-wi] > V[i-1,w] V[i,w] = b1 + V[i-1,w-wi] else V[i,w] = V[ i-1,w]
22.
0 1 2
3 4 5 0 0 0 0 0 0 0 0 3 3 3 3 0 0 3 4 0 0 0 1 2 3 4 weight I t e m Item 1 2 3 4 Weight 2 3 4 5 Value 3 4 5 6 i = 2 w = 3 wi = 3 bi = 4 w-wi = 0 if wi<=w and b1 + V[i-1, w-wi] > V[i-1,w] V[i,w] = b1 + V[i-1,w-wi] else V[i,w] = V[ i-1,w]
23.
0 1 2
3 4 5 0 0 0 0 0 0 0 0 3 3 3 3 0 0 3 4 4 0 0 0 1 2 3 4 weight I t e m Item 1 2 3 4 Weight 2 3 4 5 Value 3 4 5 6 i = 2 w = 4 wi = 3 bi = 4 w-wi = 1 if wi<=w and b1 + V[i-1, w-wi] > V[i-1,w] V[i,w] = b1 + V[i-1,w-wi] else V[i,w] = V[ i-1,w]
24.
0 1 2
3 4 5 0 0 0 0 0 0 0 0 3 3 3 3 0 0 3 4 4 7 0 0 0 1 2 3 4 weight I t e m Item 1 2 3 4 Weight 2 3 4 5 Value 3 4 5 6 i = 2 w = 5 wi = 3 bi = 4 w-wi = 2 if wi<=w and b1 + V[i-1, w-wi] > V[i-1,w] V[i,w] = b1 + V[i-1,w-wi] else V[i,w] = V[ i-1,w]
25.
0 1 2
3 4 5 0 0 0 0 0 0 0 0 3 3 3 3 0 0 3 4 4 7 0 0 3 4 5 7 0 0 3 4 5 7 0 1 2 3 4 weight I t e m Item 1 2 3 4 Weight 2 3 4 5 Value 3 4 5 6 Max Value
Download now