Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Quiz IV Questions - Analysis of Algorithms | CSIS 385, Quizzes of Algorithms and Programming

Material Type: Quiz; Class: Analysis of Algorithms; Subject: Computer Science; University: Siena College; Term: Unknown 1989;

Typology: Quizzes

Pre 2010

Uploaded on 08/09/2009

koofers-user-ycv-1
koofers-user-ycv-1 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSIS-385: Quiz 4 Name____________________________________
1. Given the following code:
fun(n) {
if (n == 0)
return;
else {
basic_op;
fun(n-1)
fun(n-1)
}
}
a. Exactly how many times it the basic
operation executed when n equal 3.
Answer:
b. What is the exact bound on the running
time, i.e., f(n)= (?)
Answer:
c. Explain how you figured out the running
time.
Answer:
2. Given the following code:
fun(a, n) {
if (n == 1)
return a;
else {
m = fun(a,n/2);
return m*m; basic_op
}
}
a. What is the output of the algorithm
when n equals 4.
Answer:
b. What is the exact bound on the running
time, i.e., f(n)= (?)
Answer:
c. Explain how you figured out the running
time.
Answer:
pf2

Partial preview of the text

Download Quiz IV Questions - Analysis of Algorithms | CSIS 385 and more Quizzes Algorithms and Programming in PDF only on Docsity!

CSIS-385: Quiz 4 Name____________________________________

  1. Given the following code: fun(n) { if (n == 0) return; else { basic_op; fun(n-1) fun(n-1) } } a. Exactly how many times it the basic operation executed when n equal 3. Answer: b. What is the exact bound on the running time, i.e., f(n)= (?) Answer : c. Explain how you figured out the running time. Answer : 2. Given the following code: fun(a, n) { if (n == 1) return a; else { m = fun(a,n/2); return mm;*  basic_op } } a. What is the output of the algorithm when n equals 4. Answer: b. What is the exact bound on the running time, i.e., f(n)= (?) Answer : c. Explain how you figured out the running time. Answer :
  1. Given the following code: fun(n) { if (n == 1) return; else { for x = 1 to n { basic_op; } fun(n/2) fun(n/2) fun(n/2) fun(n/2) } } What is the exact bound on the running time, i.e., f(n)= (?) Answer :
    1. Given the following code: fun(n) { if (n == 1) return; else { m = n/4; for x = 1 to n { for x = 1 to m { basic_op; } } fun(m); fun(m); } } What is the exact bound on the running time, i.e., f(n)= (?) Answer :
  2. What is the exact bound, i.e., f(n)= (?), on the total value of these summations: a. f(n) = n + n/2 + n/4 + n/8 + ….+ 8 + 4 + 2 + 1 Answer: b. f(n) = n^2 + (n-1)^2 + (n-2)^2 + (n-3)^2 + … + 3^2 + 2^2 + 1 Answer: