Code Matching Algorithm

I have two Java source files that do the same, give the same result. They are slightly different from the code they contain, as in the example below. I need an algorithm that measures the speed of similarity (identity) between these two java code files.

Example

/* First file */
public int inc (int n) {
    return ++n;
}

/* Second file */
public int inc (int n) {
    return (n+1);
}

Is there an algorithm that shows that these two files do the same?

Thanks in advance

+4
source share
4 answers

As Alan Turing proved almost a century ago, there is no general algorithm that could even determine if a function estimate will complete in a finite time (see Halting problem).

, , , . , , , , , , - , .

+4

. .

1: , . , .

2. , , , , . .

3. . , .

, , , .

, , , , , .

+1

, , Turnitin.

, . , .

  • "" /. x++ x+=1, x=x+1, ++x . , x++ ++x . , 100% , .

  • "" , .

, , .

: x++ x=(x+2)-1, , , , .

  1. If you program not only verification of codes, but also essays and journals. You can do text analysis when writing patterns. (For example, using the frequency of counting the word length). Some authors may prefer to use shorter words, while some prefer longer words.

  2. There are many other tests you can do to make your program dynamic. Despite the fact that there is no such algorithm, but, of course, you can write such programs to detect plagiarism.

0
source

Source: https://habr.com/ru/post/1598091/


All Articles