Well, again, just as I said verbally a moment ago, if you're going here, you're literally touching, trying to read or change memory that's beyond the boundaries of a chunk of memory that you're supposed to be touching based on its length.
嗯,再次强调,就像我刚才说的,如果你从这里出发,你将依次接触到,试着读取或者改变内存,如果超出了你可以使用的,内存块长度的界限。
And here I've got a choice. OK, one of the ways I could do would be the following.
在这种情况的数组下,我们需要考虑考虑读取时间了。
Okay good, so it's reading the responses now.
好了,现在在读取数据了
And if you've ever heard the word driver software that you install in your computer so that your computer, your operating system, Windows or Mac OS, knows how to talk to that piece of hardware, it's that driver software that then empowers the operating systems to send those commands as well, up, the data is laid out on the disk.
并且如果你听说过安装到,电脑中的驱动软件这个词的话,你的操作系统,比如Windows或者是苹果操作系统,通过这个驱动软件我们的电脑,才能知道如何与这个硬件进行通信,正是因为这个驱动软件,操作系统才能根据数据,左右移动的指令来读取磁盘里的数据。
What happened? I'm down here and try, I'm trying do get grades, which is a call to that function, which is not bound in my computer.
尝试着读取成绩,这被称为函数,是不被我的计算机局限的。
Or another way of saying it is, we're going to use as the basic steps, those operations that run in constant time, so arithmetic operations.
我们用可以在恒定时间内完成的操作,算法,比较,内存读取。
And as a consequence, access time in the list is constant, which is what I want.
这会占用一些额外的空间,回到问题本身,这么做的话,读取数组的时间就变成常量了。
What that basically says is the following: in an interpreted language, you take what's called the source code, the thing you write, it may go through a simple checker but it basically goes to the interpreter, that thing inside the machine that's going to control the flow of going through each one of the instructions, and give you an output.
也就说,如果是解释语言的话:,你要写一些叫做,源码的东西,你写的东西会经过一个简单的过滤器,然后解释器会处理你的源码,解释器会产生一个,逐条读取你的源码的,控制流,然后返回一个输出结果。
I'll draw something from the distribution, so this is interesting, distribution I'm now calling self dot distribution, and remember this will be different for each stock.
我会从分布中读取一个值,这就是有趣的部分,我现在会调用self。,请记住每只股票都是不一样的。
With this, if I can assume that accessing the i'th element of a list is constant, then you can't see that the rest of that analysis looks just like the log analysis I did before, and each step, no matter which branch I'm taking, I'm cutting the problem down in half.
读取数组中的第i个元素,是个常量时间的操作的话,我也就能像以前那样得到,这个算法是对数级复杂度的分析,并且每一步不管我选择哪个区间,我都可以把问题的规模缩小一半。
应用推荐