Write a recursive and an iterative function to calculate the nth element in a Fibonacci sequence. A Fibonacci sequence is defined as the element 1, followed by another 1, and each element thereafter is the sum of the previous two elements. For example, the first 9 elements of a Fibonacci sequence are:
This famous sequence was originally used to predict the growth of rabbit populations!
Once you have each of the functions working for n equal to 40, determine which method is more efficient by timing the two separate function calls and printing out the time required for each method call to return the 40th element in the sequence. Return the 40th element to main and print it. After that, print out a complete Fibonacci sequence from element 1 to element 40, along with its position number.
. .
. .
This last part should not be timed.
The timer function you need for this Project is:
Date d1 = new Date();
long milliseconds = D1.getTime();
OR
long start = System.currentTimeMillis();
Turn in the source, output, and a short paragraph explaining the reason the two methods took different amounts of time to execute.
Please write in JAVA
and please write recursive part and iterative part separate!
In: Computer Science
In: Finance
In: Statistics and Probability
PC Connection and CDW are two online retailers that compete in an Internet market for digital cameras. While the products they sell are similar, the firms attempt to differentiate themselves through their service policies. Over the last couple of months, PC Connection has matched CDW’s price cuts, but has not matched its price increases. Suppose that when PC Connection matches CDW’s price changes, the inverse demand curve for CDW’s cameras is given by P = 1,200 - 2Q. When it does not match price changes, CDW’s inverse demand curve is P = 900 -0.5Q. Based on this information, determine CDW’s inverse demand function over the last couple of months.
P = ____- ____ Q if Q ≤ 200
____- ____ Q if Q ≥ 200
Over what range will changes in marginal cost have no effect on CDW’s profit-maximizing level of output?
$ _____to $ _______
In: Economics
PC Connection and CDW are two online retailers that compete in
an Internet market for digital cameras. While the products they
sell are similar, the firms attempt to differentiate themselves
through their service policies. Over the last couple of months, PC
Connection has matched CDW’s price cuts, but has not matched its
price increases. Suppose that when PC Connection matches CDW’s
price changes, the inverse demand curve for CDW’s cameras is given
by P = 1,000 - 2Q. When it does not match price
changes, CDW’s inverse demand curve is P = 700
-0.5Q. Based on this information, determine CDW’s inverse
demand function over the last couple of months.
P =______ - ________ Q if Q ≤ 200
______ - _______ Q
if Q ≥ 200
Over what range will changes in marginal cost have no effect on
CDW’s profit-maximizing level of output?
$ _________ to $__________
In: Economics
PC Connection and CDW are two online retailers that compete in an Internet market for digital cameras. While the products they sell are similar, the firms attempt to differentiate themselves through their service policies. Over the last couple of months, PC Connection has matched CDW’s price cuts, but has not matched its price increases. Suppose that when PC Connection matches CDW’s price changes, the inverse demand curve for CDW’s cameras is given by P = 1,250 - 2Q. When it does not match price changes, CDW’s inverse demand curve is P = 800 -0.5Q. Based on this information, determine CDW’s inverse demand function over the last couple of months.
P = 800 - 0.5Q if Q ≤ 300
P = 1250 - 2Q if Q ≥ 300
Over what range will changes in marginal cost have no effect on CDW’s profit-maximizing level of output? $ $
In: Economics
|
Score |
Frequency |
|
0-8 |
15 |
|
9-17 |
3 |
|
18-26 |
25 |
|
27-35 |
4 |
|
36-44 |
3 |
In: Statistics and Probability
Its total output (income) is $4900. Domestic consumption is $2300; total domestic government purchases are $600; and domestic economic investment totals $1700. The nation exports $400 and imports $100.
1) Find this nation's national savings.
2) Consider again the economy from the previous question.
This economy runs a trade _______ and is a net ___________ other nations.
a. deficit; lender to
b. surplus; borrower from
c. surplus; lender to
d. deficit; borrower from
In: Economics
An Olympic diver is on a diving platform 6.40 m above the water. To start her dive, she runs off of the platform with a speed of 1.21 m/s in the horizontal direction. What is the diver's speed just before she enters the water?
m/s
A football is kicked from ground level with an initial velocity of 20.6 m/s at angle of 57.0° above the horizontal.How long is the football in the air before it hits the ground? Ignore air resistance.
s
In: Physics
A slugging average of .500 or higher is considered a sign of an excellent player. Suppose a player had 4 triples and a batting average of .300 in 400 at-bats (batting average = hits/at-bats). Determine a combination of singles, doubles, and home runs that gives this player a slugging average higher than .500. Still using 400 at-bats, what is the maximum number of singles this player could have with a slugging average between .500 and .700? Justify your answer.
In: Statistics and Probability