Due Date: Friday, Oct. 3, 2014, 23:55
See the General
Guidelines for homework assignments.
This assignment must be done individually.
1. [0 points] State what is the most advanced
programming course you have taken so far (e.g.
CS1114, CS1124, CS2114, AP CS in high school, etc.).
This is purely for assessment purposes and will not
affect your score.
For each question below,
design an algorithm that satisfies the stated
requirements. Express your answer using the pseudocode
notation covered in the course notes on Algorithms. Use
descriptive names for your variables, and include
comments as necessary. Note: if you do not
use the pseudo-code notation from the course notes, we
will not grade your submission.
2. [50 points] Design an algorithm that will use simple
arithmetic operations to estimate the base-2 logarithm
of a given positive number. The algorithm should report
the exact answer if it is an integer and otherwise state
upper and lower bounds for it. For example, given the
input 256 your algorithm should report 8, and given the
input 81 your algorithm should report the logarithm lies
between 6 and 7. Note that numbers less than 1 but
greater than zero are positive.
(Your solution may not invoke a log
function/operator.)
3. [50 points] Design an
algorithm that will take a list of numbers and the
number of values in the list, and reverse the order of
the elements in the list, without making use of a second
list variable.
|