I am designing my own algorithm to check if 2 codes are similar or identical?
How do pre-exsting softwares do this?
What logic do they use?
Are there different levels of testing for this?
please give detailed answers
I am designing my own algorithm to check if 2 codes are similar or identical?
How do pre-exsting softwares do this?
What logic do they use?
Are there different levels of testing for this?
please give detailed answers
Short answer: there is no single trick — real systems layer several techniques. Start with fast, language‑agnostic filters to cut the search space, then apply language‑aware structural checks, and finally (only when needed) deeper semantic or runtime analysis. As pointed out, ideas from sequence comparison are a useful starting point, but code needs preprocessing and parsing to be reliable.
A practical pipeline to design and evaluate:
Tradeoffs and cautions: fingerprints and token matching are fast but fragile to obfuscation (renaming, refactoring). AST and PDG comparisons are more robust but much heavier and harder for C++ because of templates and preprocessor complexity — use a compiler front end (for example Clang) rather than regex parsing. Full semantic equivalence is undecidable in the general case, so aim for heuristics + human review rather than a binary oracle.
Practical tips: exclude common libraries and boilerplate to cut noise, tune thresholds with labeled examples, keep an indexed fingerprint store for scale, and escalate matches through your pipeline rather than doing expensive analyses on every file.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.