Design & Analysis of Algorithms Ics 2301

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

TECHNICAL UNIVERISTY OF MOMBASA

Faculty of Engineering &


Technology
UNIVERSITY EXAMINATION FOR:
BACHELOR OFSCIENCE IN INFORMATION TECHNOLOGY
(BSIT 12J – Y3 S1)

ICS 2301: DESIGN & ANALYSIS OF ALGORITHM

END OF SEMESTER EXAMINATION


SERIES: APRIL 2014
TIME: 2 HOURS
Instructions to Candidates:
You should have the following for this examination
- Answer Booklet
This paper consists of FIVE questions.
Attempt question ONE (COMPULSORY) and any other TWO questions
Maximum marks for each part of a question are as shown
This paper consists of FOUR printed pages

Question One (Compulsory)


a) Give any FOUR considerations for the choice of an algorithm. (4 marks)

b) Write an algorithm for insertion sort and analyse its time complexity for the best and worst case.
(10 marks)
c) (i) Define a loop invariant. (2 marks)
(ii) Describe the loop in variant property for the insertion sort algorithm derived in question one
(b) above. (9 marks)

d) Consider the following statements in the pseudo-code below, what list of elements would be in the
Array A, Dryrun to show your answer. (5 marks)

Declare A[5] as integers


Index = 0
DOWHILE = Index < 5
A [Index] = Index * 2
Index = Index + 1
END DO

© 2014 – Technical University of Mombasa Page1


Question Two
a) Discuss the algorithm design and analysis process with suitable examples in each step.(6 marks)

b) Explain the concept of asymptotic notations indicating the commonly used notations and their
significance. (6 marks)

c) What is an optimization problem? (2 marks)

d) (i) Define recursion. (2 marks)


(ii) Compare recursive algorithm with iterative functions, use a high level language piece of code
to demonstrate the difference. (4 marks)
Question Three
a) Describe the components of algorithm that uses the divide and conquer approach to solve a
programming problem. (6 marks)

b) How would you specify a computational problem? (2 marks)

c) (i) Derive an algorithm for the mere sort. (6 marks)


(ii) Comment on the running time of the algorithm derived in question c(i) above. (2 marks)

d) Differentiate between bottom up approach and top down approach in dynamic programming.
(6 marks)
Question Four
a) Explain the necessity of time and space complexity analysis of algorithm with suitable examples.
(6 marks)
b) (i) Write an algorithm for bubble sort. (6 marks)
(ii) Apply the algorithm in question b(i) above to sort the list E, X, A, M, P, L, E
(4 marks)
c) Compute the big-oh running time of the following code segment. (4 marks)
for (i = 2, I <n; i++) {
sum + 2;
}
Question Five
a) (i) What do we mean when we say that a sorting algorithm is stable (2 marks)
(ii) Is insertion sort stable? (2 marks)

b) Describe bucket sort. (4 marks)

c) Consider the following sequential search algorithm.


Int sequentialsearch (const int a[ ], int item, int n} {
for (int I = 0; i <n a [i]! = item; Ih);
If (I = = n)
Return – 1;
Comment on the
(i) Best case
(ii) Wort case
(iii) Average case analysis for the algorithm

© 2014 – Technical University of Mombasa Page2


d) State any THREE reasons why algorithms can be considered as a technology. (3 marks)

© 2014 – Technical University of Mombasa Page3

You might also like