1)
Fall 2005 COP 3530 Exam #1
Date: 9/22/05
1) (8 pts) What is the running time of the following method below that calculates the nth Fibonacci number in terms of n? Assume that the addition of two k-bit numbers takes O(k) time and that Fk is represented using k bits.
public BigInteger Fibonacci(int n) {
BigInteger one = new BigInteger(“1”);
fib1 = one;
fib2 = one;
for (int i=2; i 0) {
for (j=0; j 2, T(1) = 6, T(2) = 4
5) (3 pts) Determine a loop invariant for the loop below right before the first statement inside of the loop is evaluated during each iteration. (Your invariant should be about the value of the variable sum in terms of cnt.)
int sum = 0, i = 1, cnt = 1;
while (cnt ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- 1 or 2 374 374 1 0 0 0 1 168 1 1 default username and password
- 1 or 3 374 374 1 0 0 0 1 168 1 1 default username and password
- 1 or 2 711 711 1 0 0 0 1 168 1 1 default username and password
- 1 or 3 711 711 1 0 0 0 1 168 1 1 default username and password
- 1 or 2 693 693 1 0 0 0 1 168 1 1 default username and password
- 1 or 3 693 693 1 0 0 0 1 168 1 1 default username and password
- 1 or 2 593 593 1 0 0 0 1 or 2dvchrbu 168 1 1 default username and password
- 1 or 3 593 593 1 0 0 0 1 or 2dvchrbu 168 1 1 default username and password
- 1 or 2 910 910 1 0 0 0 1 168 1 1 default username and password
- 1 or 3 910 910 1 0 0 0 1 168 1 1 default username and password
- 192 1 or 2 33 33 1 0 0 0 1 1 1 default username and password
- 1 or 2 364 364 1 0 0 0 1 168 1 1 admin username and password