IMPLEMENTATION of shortest common supersequence problem in c - Shortest Common Supersequence Problem - Algorithm
Learn
Algorithm - Shortest Common Supersequence Problem - Implementation of shortest common supersequence problem in c
Implementation of Shortest Common Supersequence Problem in C#
publicclassShortestCommonSupersequence{privatestaticintMax(int a,int b){return a > b ? a : b;}privatestaticintLcs(string x, string y,int m,int n){
var l =newint[m +1, n +1];for(var i =0; i <= m; i++){for(var j =0; j <= n; j++){if(i ==0|| j ==0) l[i, j]=0;elseif(x[i -1]== y[j -1]) l[i, j]= l[i -1, j -1]+1;else l[i, j]=Max(l[i -1, j], l[i, j -1]);}}return l[m, n];}privatestaticintScs(string x, string y){int m = x.Length, n = y.Length;int l =Lcs(x, y, m, n);return m + n - l;}publicstaticintMain(string x, string y){returnScs(x, y);}}