“Partial match” table (aka “failure function”) in KMP (on wikipedia)

倾然丶 夕夏残阳落幕 提交于 2019-12-06 12:11:33

You can fall back to T[cnd] because it contains the length of the previous longest proper prefix of the pattern W which is also the proper suffix of W[0...cnd]. So if the current character at W[pos-1] matches the character at W[T[cnd]], you may extend the length of longest proper prefix of W[0...pos-1] (which is the first case).

I guess it's kind of like dynamic programming where you rely on previously computed values.

This explanation might help you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!