ECE-1021

HOMEWORK #4

(Last Mod: 27 November 2010 21:38:41 )

ECE-1021 Home


PROGRAM A - Mystery Algorithm

The complete pseudocode for one of the classic computational algorithms is available in the file 04a0soln.txt. Implement this algorithm and try to determine the functional relationship between the input values and the output values. For instance, is the output value the natural logarithm of the input value?

Part 1) Draw the flowchart that corresponds to the provided pseudocode. This may be done either electronically or by hand. If electronic, turn in a hardcopy printout of your flowchart.

Part 2) Work through the algorithm by hand using the following values for "x": {2, 20,000, 0.002}. Use a value of 3 for "sig" in each case. What is your hypothesis concerning the functional relationship between "x" and the generated output? Work through the algorithm for at least two other values meant to prove or disprove your hypothesis.

Part 3) Implement the algorithm in C and use it to generate the output for all of the values used as input in Part 2 plus several other values. Place a table of the inputs and outputs in the comments of your program just below the header. The functional relationship should be included in the program subtitle (where it presently says UNKNOWN in the pseudocode header).

PROGRAM B - Find (and fix) the bug (EXTRA CREDIT)

The above algorithm has a bug in it that causes it to produce incorrect results if the relationship between "x" and "sig" satisfy particular requirements. See if you can:

Part 1) Identify, at least in general terms, what the bug is.

Part 2) Describe explicitly (i.e., mathematically) what the requirements are for the bug to manifest itself.

Part 3) Modify the algorithm to overcome the bug.

Part 4) Modify the program to overcome the bug.