English subtitles

← Simple Mechanical Algorithm - Intro to Computer Science

Get Embed Code
2 Languages

Showing Revision 5 created 05/25/2016 by Udacity Robot.

  1. And the answer is a few milliseconds. So here's why. We have a 100 years. A year
  2. is roughly 365. If it is a leap year, it's one more, but we're going to have
  3. somewhere around 36,000 days. A modern processor can do about a billion
  4. instructions per second, so that's means 1 nano second per instruction. And now,
  5. these aren't instructions like statements in a Python program. Each statement in
  6. Python program probably involves several instructions for the processor. So
  7. we're going to estimate that for each time through this loop, we're going to
  8. need about a 1,000 instructions. And that's the hardest part of this to guess
  9. and that's a very rough number. That's going to depend on a lot of specifics
  10. about how we write the Python code. But it's going to be somewhere between a few
  11. 100 and say 10,000 instructions if we do it in a sensible way. So we'll estimate
  12. a 1,000 instructions. So that means we need a 1,000 instructions times 36,000
  13. days, so we need about 36 and a half million instructions total. If we were
  14. executing this as a human, we'd certainly would not want to do this. But for a
  15. processor, they can do a billion instructions in a second, doing 36 million
  16. instructions is no big deal. So that's going to be about 36 million nanoseconds,
  17. which is 36 milliseconds, which is 0.036 seconds.