| 2012-2013 ICS4U SOFTWARE ENGINEERING TASKS |
TASK 'CHALLENGE' RATING (offered
to assist you with project management strategies) |
||
Routine |
Typically some deep thinking required,
but not necessarily a lot of coding. |
|
Hard |
Likely involves either a multiplicity
of (possibly new) concepts or algorithms. Allow time. |
|
Buckle Up |
Start immediately, think
hard, employ a stepwise refinement strategy and post concerns
as required. |
|
The Golden Ratio, φ. In class we investigated
the relationship between the sequence defined by the quotients of successive
terms of the Fibonacci sequence
and the Golden Ratio, φ. This can be expressed as,
![]() |
(GR-1) |
A compelling topic in pure mathematics is Continued Fractions. The essential idea is that the deeper the evaluation of these expressions, the better the approximation is to the ultimate irrational target, or what we prefer to call it in Calculus, the limit. The programmatic evaluation of these expressions is a good fit with your understanding of recursive methods. Here is one example of the continued fraction for the Golden Ratio.
![]() |
(GR-2) |
The limit of both of these sequences is φ.
Task. Develop a java project called GoldenRatio, the output of which will allow the viewer to confirm that both sequences (1) and (2) converge on φ. You will maximize your use of recursive methods, but beyond that, the design of the classes and methods are yours to decide based on our efforts last year. Beyond the correct answer, my evaluation of your submission will focus on the elements of good programming: class and method design, efficient implementation, strong documentation and highly intuitive output. Finally, keep in mind the following,
The first two terms of the fibonacci sequence are defined as
t1=t2=1.
All remaining
terms
are defined as the sum of the previous 2 terms.public int fib (int n) that
iteratively determines and returns the nth term of the fibonacci
sequence. What is the Big-O of
this implementation?public
int fib (int n) that
exercises this definition. What is the Big-O
of this
implementation?
Powers. It is virtually impossible to provide practical
programming solutions to a variety of complex problems without recursion.
As such, it is an indispensable programming
strategy.
Having said this, you'll have to decide when it's warranted.
Successful implementation of a recursive solution depends on your ability to
define a recursive solution on paper.
For example, the power function, xn can be defined iteratively (non-recursively) as,
Defined recursively, we could write,
| (P-1) |
From (1), the implementation is straightforward. Successful recursive solutions arise from the programmer being able to express a definition similar to (1) for each new problem, that includes both the general recursive substitution expression and a basis or stopping condition.
Tasks.
public int powerIterative(int x, int n) that
determines and returns the value of xn, iteratively. What is the Big-O of this implementation?public int powerRecursive(int x,
int n) that determines and returns the value of xn, recursively. What is the Big-O of this implementation?public int pow2(int n) that computes the value of 2n with
a running time of O(1).
Number of Paths. Consider Problem 15 of Project Euler.