![]() |
![]() |
|
home—info—lectures—exams—archive
nod : N -> N, "number of digits": returns the number of digits of a number. nod(999) = 3, nod(1000) = 4, nod (9999) = 4. (nod(1)=1, so I guess nod(0)=0.) Note that this actually depends on the base -- so let nod10 be number-of-digits-if-written-base-10, and nod2 be number-of-bits, nod16 is number-of-hex-digits, etc. nod2(17) = ? A few interesting properties of nod, roughly: nod(a*b) =~ .. nod(a+b) tends either ... or ... nod(10^k) = nod(b^a) = Sound familiar? Sure! nod is like log. (More exactly: nod_k(n) = floor(log_k(n))+1) To computer scientists, 'log' is *though of* as 'number of digits (plus 1)'. ====== Play hi-lo. Run-time? WHat is the run-time of Mergesort? A: O(n log(n)): you make log(n) recursive calls; each call also does O(n) work to 'unzip' and O(n) work to merge, for 2n log(n).
home—info—lectures—exams—archive
©2008, Ian Barland, Radford University Last modified 2008.Nov.08 (Sat) |
Please mail any suggestions (incl. typos, broken links) to ibarland ![]() |
![]() |