Let's say you have to go through three or four operations to get a final number, well, do it algebraically.
让我们说,你不得不通过3-4个操作,才能得到最终的数,好吧,用代数方法求解。
So I'm first going to look for something that's not in the list, I'm going to see, is minus 1 in this list, so it's going to be at the far end, and if I do that in the basic case, bam.
如果我试试第一种最基本的方法,噢,一下就完成了对不对?,因为这种方法查了下第一个元素,然后发现目标数比较下,因为目标数小于第一个元素。
So what do you do when you're a kid and you want 3 to count a little faster than 1 and 2 and 3 and 4 what is the simplest thing you do?
因此当你还是个孩子的时候,你想数得比1,2,3,4快一些3,最简单的方法是什么?
Most censuses were taken, by the way, as a way of counting heads, the number of people who had to be fed at the time of a siege.
顺便提一下,大多数人口普查,都采用数人头的方法,即在围城期间统计需要给养多少人口
Do what you normally do with ordinary numbers.
就按照通常处理数的运算的方法去做
Let's search to see though now if a million is in this list, or 10 million, whichever way I did this it must be a million, right?
不管我选哪个,数都挺大的对不对?,用嘴基本的方法,噢,花的时间有点长,好,而用二分法呢?
In fact, my program crashes because I end up trying to divide by zero, a really bad thing. Hint: if you implement Newton's method, do not make your first guess zero.
我下一步都没法开始,实际上,我的程序会崩溃,因为我试着去除0了,真糟糕,提示你:如果你想用牛顿的方法,第一个猜想数别设为0。
It means anybody using that little function get float doesn't have to worry about what's inside of it. So for example, I decide I want to change the message I print out, I don't have to change the function, I just pass in a different parameter.
这代表着用这个方法去获得浮点数,的任何人都不用担心具体的实现了,例如,如果我想改变下,显示的信息的话,我不必去改变方法,我传个不同的参数就可以了。
Well I'm relying on the contract, if you like, that the manufacturer of square root put together, which is, if I know I'm giving it two floats, which I do because I make sure they're floats, the contract, if you like, of square root says I'll give you back a float.
好吧我能靠一些类似合约来保证,如果这么说你喜欢的话,其实就是当求平方根的方法,获得了两个我已经确认了是浮点数的数后,这个类似合约的东西就会保证,返回一个浮点数。
应用推荐