So I'm going to solve this by enumerate and check, which is an example of what's called a brute-force algorithm.
你懂的,所以我得靠列举和检验来解决这个问题,这就是我们说的穷举算法。
So this is a nice little search-- sorry, a nice little sort algorithm . And in fact, it's relying on something that we're going to come back to, called the loop invariant.
恩,这是一个很棒的小搜索,抱歉,和很棒的小排序算法,事实上,它依赖于一些我们要回顾的东西,被称作循环不变量。
And so ease of implementation is actually a very compelling -- metric against which to measure-- -- do you mind toning my voice down a bit-- is a very reasonable measure against which to measure the quality of an algorithm, right.
如此简单的实现实际上是一个很牵强的,度量,与之相对的衡量是-,如果你们不介意,我降低点音量-,是一种用来度量算法质量的,合理的方法。
and we like log algorithms, because they're really fast. A typical characteristic of a log algorithm is a pro-- or sorry, an algorithm where it reduces the size of the problem by a constant factor.
并且我们也很喜欢对数算法,因为它很快,对数算法的典型特性是高速,哦,抱歉,是他能以常数因子的速度,降低问题的大小,很明显。
PROFESSOR: Great question. So the question is, how do you choose an algorithm, why would I choose to use a pseudo-polynomial algorithm when I don't know how big the solution is likely to be, I think that's one way to think about it.
教授:问得好,所以问题是,你怎样选择算法,为什么当我,不知道解决方案会有多大的时候,我要选伪多项式算法呢,我想这是一种思考问题的方式。
I think one of the classic ones for strings is called the Rabin-Karp algorithm. And it's simply the same idea that you have a mapping from your import into a set of integers.
我认为字符串哈希,最经典的是Rabin-Karp算法,它只是简单的相同概念,你有一个映射关系将你的输入映射成一组数字。
应用推荐