Boy, there's a dumb question, because I've been telling you n log n for the last two lectures the complexity is n log n, but let's see if it really is.
孩子们,这是一个愚蠢的问题,因为前两节课的时候我就已经告诉你们了,复杂度是,但是让我们来看一下是不是真的是这样。
In the linear case, meaning in the unsorted case what's the complexity of this? k times n, right? Order n to do the search, and I've got to do it k times, so this would be k times n.
复杂度是多少?k的n次方,对吧?,在序列n中做搜索,要做k次,所以是k的n次方次,如果先排序后搜索。
The order complexity here, if I actually write it would be-- sorry, order n times m, and if m was equal to n, that would be order n squared, and this is quadratic.
如果m等于n的话,也就是n的平方,这是一个平方复杂度的问题,这是和前面不同类型的,好,我在做什么呢?
应用推荐