Subject: hw 2 (hints)

From: [email-masked] (Chee Yap)
Date: Tue, 29 Sep 1998 10:23:41 -0400

Dear Class:

Here are some hints on doing hw 2.
Please remember to do this hw early
rather than wait till the last moment.

In view of the Jewish holidays,
I will allow you to hand in the solution
by Thursday midnite.

--Chee

*****************************************************************

PROBLEM R-2.5:

	-- you can systematically sort the list of functions
		by "insertion sort".  That is, you maintain
		the sorted order of all the functions seen
		so far, and for each new function, you "insert"
		it into the list (using binary search, for example).
	-- alternatively, sort each row of functions,
		then "merge" two lists at a time until there is
		only one sorted list.

PROBLEM R-2.6:
	-- You will need a pocket calculator to do this problem.
		(Note: if you write programs to do this problem,
		you need to take care that the big numbers do not overflow)
	-- To make life easier for you, let me say that I am mainly
		interested in the order of magnitude.  It is enough
		it you write your answers with only TWO significant
		digits, in the following "scientific notation":

			d.d x 10 ^ e
		
		For example,
			1.2 x 10^{2345}
			3.4 x 10^{-10}

	-- If a number is too big for your pocket calculator, you can
		use well known tricks.  For instance, if you want
		to take the natural log of a huge number N that is too big
		for your calculator, then you need to first write N as
		a product of two smaller numbers:  N = N1 x N2.
		Then log(N)=log(N1)+log(N2).  Often, such factors of N
		are easily obtained.

	-- The easiest row to fill in is the row labeled by "n".
		Do this one first.
	-- Next, rows "sqrt(n)" and "n^2" are pretty easy -- you only need to
		take the square and square root of the corresponding
		entries in the "n" row.
	-- The hardest rows are: "n log n" and "n!".

		Here, you basically need to do trial and error search.
		Of course, as computer science majors, you use binary
		search: if m=10 is too small, and m=100 is too big, then
		you try m=50 (or m=55), etc.

	-- HERE IS A BIG HINT FOR "n!": use the approximation

			log(n!) = n log(n)  - n + o(n).

		Here, the logs are to the base e (natural log).  You
		may ignore the o(n) term in your calculations.