selmi-karim / z-algorithm

algorithm able to finds all occurrences of a pattern in a text in linear time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Z algorithm (Linear time pattern searching Algorithm)

This algorithm finds all occurrences of a pattern in a text in linear time. Let length of text be n and of pattern be m, then total time taken is O(m + n) with linear space complexity.

Now we can see that both time and space complexity is same as KMP algorithm but this algorithm is Simpler to understand.

Install

npm install z-algorithm --save

or 

yarn install z-algorithm

Running the tests

you need to install jest

npm test

or 

yarn test

Usage

import z from 'z-algorithm';

let result = z.search('Hello World', 'Hello'); 

Examples

import z from 'z-algorithm';
        

Author

kerim selmi karimation

License

This project is licensed under the MIT License

About

algorithm able to finds all occurrences of a pattern in a text in linear time

License:MIT License


Languages

Language:JavaScript 100.0%