Git Product home page Git Product logo

string_processing_algorithms's Introduction

String processing Algorithms

Copyright 2021 Adina-Maria Amzarescu 321CA

This is a project that tests 2 string processing algorithms, Rabin-Karp and Knuth-Morris-Pratt. The algorithms were tested in C language.


Rabin-Karp - approximate match

It checks the pattern by moving window one by one, but without checking all characters for all cases, it finds the hash value. When the hash value is matched, then only it tries to check each character. This procedure makes the algorithm more efficient.

The time complexity is O(m+n), but for the worst case, it is O(mn).


Knuth-Morris-Prat - exact match

It is an algorithm which checks the characters from left to right. When a pattern has a sub-pattern appears more than one in the sub-pattern, it uses that property to improve the time complexity.

The time complexity of KMP is O(n).


Tests

For testing the 2 aglorithms I created 40 tests. You can find them in input.

For both algorithms I used the same tests. As you can see, the results are the same. You can find the output of each algorithm in out-rk and out-kmp.

Details

  • Multiple spacing (test 1, 2, 5, 7)

  • Large and small texts

  • Binary text (test 4)

  • The pattern is not found (tests 5, 12, 14, 19, 36 and 40)

  • A single letter search (tests 7 and 11)

  • Word and phrase searching

  • One text contains only one letter (test 3)

  • The 15th test is empty

  • I also have tests that contain only

    • numbers (tests 16, 17 and 18)

    • letters

      • lower (tests 30 and 31)
      • upper (tests 32 and 33)
      • mixt (tests 27, 28 and 29)
    • symbols (tests 19, 20 and 21)

  • Tests 22 to 25 have as a pattern a paragraph

  • The 26th test has the same pattern and text

  • Since those 2 algorithms are used to detect plagiarism I included 5 tests (34 to 38) in which the text is a senior thesis

  • Also those 2 algorithms are used to detect abnormalities in the genetic code, I also included 2 tests (38 and 39) in which the text is a DNA sequence


In order to test other files, you need to add them in the in_files array and change the NRFILES macro.

In every input file you can find the pattern on the first line and then the text.

string_processing_algorithms's People

Contributors

adinaamzarescu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.