Originally Posted By: Jay_Reynolds_Freeman
Problem 4 solution:
The intuition here is that if register 1 contains a zero, then the input number n is zero, and the answer is zero; if not, then we can use register 1 as scratch space, which we will need to do the more general case of the problem. With that in mind, we proceed with either psuedocode or actual RAM instructions on the left and in any case actual RAM instructions on the right. Sometimes it takes several actual RAM instructions to implement one line of psuedocode.
This answer is different from the one presented in class, I think I found an off-by-one error in that one ...
The web site does not like to format things neatly; I have added lots of "."s to line up things in columns, and it probably still won't work ... ...
....................................Statement #
acc Jay_Reynolds_Freeman — Mon May 16, 2011 3:46 pm
<hr>
'''Originally Posted By: Jay_Reynolds_Freeman'''
Problem 4 solution:<br><br>The intuition here is that if register 1 contains a zero, then the input number n is zero, and the answer is zero; if not, then we can use register 1 as scratch space, which we will need to do the more general case of the problem. With that in mind, we proceed with either psuedocode or actual RAM instructions on the left and in any case actual RAM instructions on the right. Sometimes it takes several actual RAM instructions to implement one line of psuedocode.<br><br>This answer is different from the one presented in class, I think I found an off-by-one error in that one ...<br><br>The web site does not like to format things neatly; I have added lots of "."s to line up things in columns, and it probably still won't work ... ...<br><br>....................................Statement #<br>acc Jay_Reynolds_Freeman — Mon May 16, 2011 3:46 pm
<hr>