Skip to content

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

License

Notifications You must be signed in to change notification settings

selmi-karim/z-algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published