= [C, B, A, B, A, C] (0, 0) A B C A B B A C B A B A C 0 1 2 3 4 5 0 1 2 3 4 5 6 source target NBUDIQPJOU QPJOUBTTBNFTZNCPM (7, 6) &EHFʹԊͬͯɺ4UBSU͔Β&OE·ͰҠಈ͢Δ ӈɾԼɾࣼΊํͷҠಈ㲈EFMFUF JOTFSU EPOPUIJOH 4UBSU &OE 4UBSU &OE
= [C, B, A, B, A, C] (0, 0) A B C A B B A C B A B A C 0 1 2 3 4 5 0 1 2 3 4 5 6 source target NBUDIQPJOU QPJOUBTTBNFTZNCPM (7, 6) 4&4 4UBSU &OE 4UBSU࠲ඪ&OE࠲ඪͷ࠷ܦ࿏ 4UBSU &OE
0 1 2 3 4 5 6 Delete A Delete B 3JHIU.PWFNFOU #PUUPN.PWFNFOU %JBHPOBM.PWFNFOU EFMFUF JOTFSU EPOPUIJOH TBNFTZNCPM NBUDIQPJOU QPJOUBTTBNFTZNCPM Insert B Insert C source = [A, B, C, A, B, B, A] target = [C, B, A, B, A, C] A B C A B B A C B A B A C target Delete B 4UBSU &OE source 4UBSU &OE
A] target = [C, B, A, B, A, C] (0, 0) 0 1 2 3 4 5 (7, 6) 0 1 2 3 4 5 6 Delete A Delete B NBUDIQPJOU QPJOUBTTBNFTZNCPM Insert B Insert C A B C A B B A C B A B A C target Delete B 4UBSU &OE ࠷ܦ࿏ͷ૯Ҡಈίετ % 4&4ͷεΫϦϓτ source 4UBSU &OE
0 1 2 3 4 5 6 Delete A Delete B NBUDIQPJOU QPJOUBTTBNFTZNCPM Insert B Insert C source = [A, B, C, A, B, B, A] target = [C, B, A, B, A, C] A B C A B B A source C B A B A C target Delete B 4UBSU &OE 3 1 x - y = k 0 -1 2 Y Z 4UBSU &OE
0 1 2 3 4 5 6 Delete A Delete B NBUDIQPJOU QPJOUBTTBNFTZNCPM Insert B Insert C source = [A, B, C, A, B, B, A] target = [C, B, A, B, A, C] A B C A B B A source C B A B A C target Delete B 4UBSU &OE 3 1 x - y = k 0 -1 2 Y Z k + 1 k - 1 k 4UBSU &OE
0 1 2 3 4 5 6 Delete A Delete B NBUDIQPJOU QPJOUBTTBNFTZNCPM Insert B Insert C source = [A, B, C, A, B, B, A] target = [C, B, A, B, A, C] A B C A B B A source C B A B A C target Delete B 4UBSU &OE 3 1 0 -1 2 Y Z k + 1 k - 1 k ඇର֯ͳҠಈΛ%ճߦͬͨ࠷ͷܦ࿏ %͕حͳΒLحͷର֯ઢ %͕ۮͳΒLۮͷର֯ઢ্Ͱࢭ·Δ 4UBSU &OE
k ← -D to D in steps of 2 Do Until D Path gets to furthest point Do Move on edges If (N, M) is the reached point Then Found the SES. Array[with: k] M = source.count N = target.count %͕حͳΒLحͷର֯ઢ %͕ۮͳΒLۮͷର֯ઢ্Ͱࢭ·Δ &EJU(SBQI্Ͱ࠷ԕͷύε֎प Complexity: O((M+N)D) ίετ%Ͱߦ͚ͨ࠷ԕͷ࠲ඪΛLઢຖʹه %શͯԼҠಈ %શͯӈҠಈ &OE࠲ඪ
Communications of the ACM, 21: 264–268, doi:10.1145/359460.359467, retrieved 2011-12-04 ɾE. W. Myers, ‘‘An O(ND) difference algorithm and its variations,’’ Algorithmica, 1 (1986), pp. 251−266. 3FGFSFODFT