什么是Naive algorithm



Naive algorithm

这篇文章是转载来的,这个应该是翻译成朴素算法吧。翻译成简单算法感觉不是很高大上。。读者觉得不对的,请指出。。

源地址:http://wcipeg.com/wiki/Naive_algorithm#

From PEGWiki

An algorithm is said to be naive when it is simple and straightforward but does not exhibit a desirable level ofefficiency (usually in terms of time, but also possibly memory) despite finding a correct solution or it does not find an optimal solution to anoptimization problem, and better algorithms can be designed and implemented with more careful thought and clever techniques. Naive algorithms are easy to discover, often easy to prove correct, and often immediately obvious to the problem solver. They are often based on simplesimulation or onbrute force generation of candidate solutions with little or no attempt at optimization. Despite their inefficiency, naive algorithms are often the stepping stone to more efficient, perhaps even asymptotically optimal algorithms, especially when their efficiency can be improved by choosing more appropriatedata structures.

For example, the naive algorithm for string searching entails trying to match the needle at every possible position in the haystack, doing an O(m) check at each step (where m is the length of the needle), giving anO(mn) runtime (where n is the length of the haystack). The realization that the check can be performed more efficiently using a hash function leads to theRabin–Karp algorithm. The realization that preprocessing the needle can allow a failed attempt at matching to be used to rule out other possible positions leads to theKnuth–Morris–Pratt algorithm. The realization that preprocessing the haystack can allow needles to be "looked up" in the haystack rather than searched for in a linear fashion leads to thesuffix tree data structure which reduces string search to mere traversal. All of these algorithms are more efficient than the naive algorithm.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值