diff --git a/dynamic_programing/longest_common_subsequence/java/lcs.class b/dynamic_programing/longest_common_subsequence/java/lcs.class new file mode 100644 index 0000000..908cf78 Binary files /dev/null and b/dynamic_programing/longest_common_subsequence/java/lcs.class differ diff --git a/dynamic_programing/longest_common_subsequence/java/lcs.java b/dynamic_programing/longest_common_subsequence/java/lcs.java new file mode 100644 index 0000000..f30d6d5 --- /dev/null +++ b/dynamic_programing/longest_common_subsequence/java/lcs.java @@ -0,0 +1,40 @@ + +import java.util.*; +public class lcs +{ + + /* Returns length of LCS for X[0..m-1], Y[0..n-1] */ + int lcs( char[] X, char[] Y, int m, int n ) + { + if (m == 0 || n == 0) + return 0; + if (X[m-1] == Y[n-1]) + return 1 + lcs(X, Y, m-1, n-1); + else + return max(lcs(X, Y, m, n-1), lcs(X, Y, m-1, n)); + } + + + int max(int a, int b) + { + return (a > b)? a : b; + } + + public static void main(String[] args) + { Scanner sc=new Scanner(System.in); + lcs ob = new lcs(); + String s1 = sc.nextLine(); + String s2 = sc.nextLine(); + + char[] X=s1.toCharArray(); + char[] Y=s2.toCharArray(); + int m = X.length; + int n = Y.length; + + System.out.println("Length of LCS is" + " " + + ob.lcs( X, Y, m, n ) ); + + sc.close(); + } + +} \ No newline at end of file diff --git a/sort/selection_sort/c++/a.out b/sort/selection_sort/c++/a.out new file mode 100755 index 0000000..b65f11b Binary files /dev/null and b/sort/selection_sort/c++/a.out differ diff --git a/sort/selection_sort/c++/selectionsort.cpp b/sort/selection_sort/c++/selectionsort.cpp new file mode 100644 index 0000000..29552c2 --- /dev/null +++ b/sort/selection_sort/c++/selectionsort.cpp @@ -0,0 +1,37 @@ +#include +using namespace std; + +int main() +{ + int n,i,j,index; + long long a[100000],small; + cin>>n; + + for(i=0;i>a[i]; + + + + for(i=0;i