From 5c412536a3f4913207543c3c0f839670f0a8f2b5 Mon Sep 17 00:00:00 2001 From: Raghav Tyagi <111491963+SimplyHumanic@users.noreply.github.com> Date: Tue, 11 Oct 2022 22:59:00 +0530 Subject: [PATCH] Create DSA.ALGO123 --- DSA.ALGO123 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 DSA.ALGO123 diff --git a/DSA.ALGO123 b/DSA.ALGO123 new file mode 100644 index 0000000..64a22fa --- /dev/null +++ b/DSA.ALGO123 @@ -0,0 +1,14 @@ +X and Y be two given sequences +Initialize a table LCS of dimension X.length * Y.length +X.label = X +Y.label = Y +LCS[0][] = 0 +LCS[][0] = 0 +Start from LCS[1][1] +Compare X[i] and Y[j] + If X[i] = Y[j] + LCS[i][j] = 1 + LCS[i-1, j-1] + Point an arrow to LCS[i][j] + Else + LCS[i][j] = max(LCS[i-1][j], LCS[i][j-1]) + Point an arrow to max(LCS[i-1][j], LCS[i][j-1])