Skip to content

Latest commit

 

History

History
61 lines (30 loc) · 980 Bytes

File metadata and controls

61 lines (30 loc) · 980 Bytes

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