Advanced Programming I Code Review for Programming Assignment 2

Advanced Programming I Lecture Notes

28 February 2006 • Assignment 2 Code Review


To get an idea of how big 2×1031 is, suppose it were possible to execute the body of the while loop in 1 nanosecond. There are 109 nanoseconds in a second, which means it would take

2×1031 values / 109 values/sec = 2×1022 sec

to seach through all values (which is the worst case). There are roughly 31×106 seconds in a year, giving

3×1022 sec / 31×106 sec/year = 6.4×1014 years

to search through all the values. In comparison, the universe is believed to be between 10 and 20 billion years old.


This page last modified on 24 January 2006.