Você está na página 1de 3

The Islamia University of Bahawalpur

Examination: Final Term BSCS 5th (M&E)


Paper: Analysis of Algorithm Total Marks=50
Time: 2 Hrs
Name:…………………….. Roll#:……………….

NOTE: Please solve first question on question paper and return it after Twenty
minutes.

Q#1 Do as appropriate (20)

1. The time factor when determining the efficiency of algorithm is measured by


a. Counting micro seconds b. Counting the number of key operations
c. Counting the number of statements d. Counting the kilobytes of algorithm

2 The space factor when determining the efficiency of algorithm is measured by


a. Counting the maximum memory needed by the algorithm b. counting the minimum memory needed by
the algorithm
c. counting the average memory needed by the algorithm d. counting the maximum disk space
needed by the algorithm

3. The indirect change of the values of a variable in one module by another module is called
a. internal change b. inter-module change
c. side effect d. side-module update
4. Two main measures for the efficiency of an algorithm are
a. Processor and memory b. Complexity and capacity
c. Time and space d. Data and space

5. Which of the following case does not exist in complexity theory


a. Best case b. Worst case
c. Average case d. Null case

6. Locally optimal decisions which cannot change once made


a. Dynamic algorithm b. Greedy algorithm
c. Divide and Conquer algorithm d. None of Then

7. The complexity of linear search algorithm is


a. O(n) b. O(log n)
c. O(n2) d. O(n log n)

8. The complexity of Binary search algorithm is


a. O(n) b. O(logn )
c. O(n2) d. O(n log n)
9. The complexity of Bubble sort algorithm is
a. O(n) b. O(log n)
2
c. O(n ) d. O(n log n)

10. The complexity of merge sort algorithm is


a. O(n) b. O(log n)
c. O(n2) d. O(n log n)

11.Time Complexity of General divide and Conquer algorithm is T(n)=

a. { 2T(n/2) +S(n)+M(n) n≥c and b, n≤ c b. { 2T(n/2) +S(n)+M(n) n≥c and b, n< c

c. { 2T(n/2) +S(n)+M(n) n≤c and b, n< c d. { 2T(n/2) +S(n)+M(n) n< c and b, n≥c

12. To prime test a number with n binary digits by brute force, we need to check number
a. Q(n), b. O(logn)
c. 2n d. n
13 In merge sort merge procedure contains how man loops
a. 2 b. 4
c. 3 d. None of Then
14. We can visualize Merge-sort by means of ………. where each node of the tree represents a
recursive call
a. Linear Tree b. Binary Tree
c. Complex Tree d. None of Then

15. The computational cost of Q(sqr(n)) much faster Then Q(n).T/F


16 The Worst case occurs in linear search algorithm when Item is the last element in the array or is
not there at all. T/F
17. The complexity of linear search algorithm is O(logn). T/F
18. The computational cost is Q(n/2) and the cost in terms of binary operation is Q(2n-1).T/F
19. The brute-force prime testing requires exponential time with the n number of digits. T/F
20 The complexity of the average case of an algorithm is much more complicated to analyze than
that of worst case. T/F

GOOD LUCK
Q#2 (7+3)
a) Find the merge algorithm complexity by substitution method
b) Prove that If n Î N, n > 1 is not prime then n is divisible by some prime number p ≤
square root of n.

Q#3 (7+3)
Write the Quick sort algorithm and Find the complexity.

Q#4 (5+5=10)
Start with a different kind of pair of rabbits, one male and one female, born on January 1.
Assume all months are of equal length and that rabbits begin to produce three months after their own
birth. After reaching age of three months, each pair produces another mixed pairs, one male and
other female, and then another mixed pair each month, and no rabbit dies.
How many pairs of rabbits will there be after 8 Months?
NOTE: Construct the graphical and mathematical Model.
.
GOOD LUCK

Q#2 (7+3)
a) Find the merge algorithm complexity by substitution method
b) Prove that If n Î N, n > 1 is not prime then n is divisible by some prime number p ≤
square root of n.

Q#3 (7+3)
Write the Quick sort algorithm and Find the complexity.

Q#4 (5+5=10)
Start with a different kind of pair of rabbits, one male and one female, born on January 1.
Assume all months are of equal length and that rabbits begin to produce three months after their own
birth. After reaching age of three months, each pair produces another mixed pairs, one male and
other female, and then another mixed pair each month, and no rabbit dies.
How many pairs of rabbits will there be after 8 Months?
NOTE: Construct the graphical and mathematical Model.

GOOD LUCK

Você também pode gostar