Docsity

data structure and algorithm mid exam, Exams of Data Structures and Algorithms

Toggle sidebar
bg1
1. Let x denote the degree of polynomial f(n), and y the degree of polynomial g(n). If f(n) =
o(g(n)), then necessarily
a. x = y.
b. x< y.
c. x > y.
d. a&b
2. If f(n) = O(g(n)) and f(n) = Ω(g(n)then it is always true that
a) f(n) = o(g(n)).
b) f(n) = theta(g(n)).
c) f(n) = (g(n)).ꙍ(g(n)).
d) all.
3. If T1(n)=O(f(n)) and T2(n)=O(g(n)) then T1(n)+T2(n) will be?
a) O(f(n))+ O(g(n))
b) O(f(n))* O(g(n))
c) Max of O(f(n)), O(g(n))
d) Average of O(f(n))+ O(g(n))
4. Which one of the following alternative is true about the following algorithm
int f4(int n)
{if (n < 10)
{System.out.println("!");
return n+3;}
else {return f4(n-1) + f4(n-1);}}
a)O(n^2)
b)O(2n)
c)O(n)
d)O(1)
5. “It must solve with the least amount of computational resources such as time and
space.” Is belong to which property of the algorithm
a) Finiteness
b) Completeness
c) Effectiveness
d) Efficiency
pf3
pf4
Discount

On special offer

Partial preview of the text

Download data structure and algorithm mid exam and more Exams Data Structures and Algorithms in PDF only on Docsity!

  1. Let x denote the degree of polynomial f(n), and y the degree of polynomial g(n). If f(n) = o(g(n)), then necessarily a. x = y. b. x< y. c. x > y. d. a&b
  2. If f(n) = O(g(n)) and f(n) = Ω(g(n)then it is always true that a) f(n) = o(g(n)). b) f(n) = theta(g(n)). c) f(n) = ꙍ(g(n)).(g(n)). d) all.
  3. If T1(n)=O(f(n)) and T2(n)=O(g(n)) then T1(n)+T2(n) will be? a) O(f(n))+ O(g(n)) b) O(f(n))* O(g(n)) c) Max of O(f(n)), O(g(n)) d) Average of O(f(n))+ O(g(n))
  4. Which one of the following alternative is true about the following algorithm int f4(int n) {if (n < 10) {System.out.println("!"); return n+3;} else {return f4(n-1) + f4(n-1);}} a)O(n^2) b)O(2n) c)O(n) d)O(1)
  5. “It must solve with the least amount of computational resources such as time and space.” Is belong to which property of the algorithm a) Finiteness b) Completeness c) Effectiveness d) Efficiency
  1. Which one of the following is correct about the empirical analysis of algorithm a) Is affected by processors speed b) It use arbitrary time for analysis c) Affected by operating environment d) A&c
  2. Which types of searching algorithm is time consuming on given set of n value a) Insertion b) Linear c) Binary d) Bubble
  3. Which one is not true about insertion sort a) N swaps b) N^2 comparison c) Most instinctive sorting types d) All
  4. Which sorting types is the slowest on large inputs a) Sequential b) Bubble c) Selection d) Insertion
  5. f(n)=theta of(g(n)) if and only if g(n)=theta(f(n))is shows which relational properties of asymptotic notation a) Transitivity b) Symmetry c) Reflexivity d) Transpose symmetry III blank space (1pt each)

void Sort (int list[ ] ) int list[] = {5, 3, 7, 4, 6}; { int minIndex, temp; for (int i = 0; i <= n - 2; i++) { minIndex = i; for (int j = i + 1; j <= n-1; j++) if (list[j] < list[minIndex]) minIndex = j; if (minIndex != i) { temp = list[i]; list[i] = list[minIndex]; list[minIndex] = temp; } } }

4. List and discuss notations used to describe a running time function(2pt)