ICS 2301 Design and Analysis of Algorithms
ICS 2301 Design and Analysis of Algorithms
QUESTION 1 (ONE)
a) A good knowledge of algorithm design and analysis form an integral part of computer
science solutions
i. Elucidate the term algorithm
(2marks)
ii. Describe five criteria that must be satisfied by an algorithm (3marks)
iii. Give Four practical applications of algorithms (4 marks)
c)
ii. There are 8, 15, 13, and 14 nodes in 4 different trees. Which one of them can form a
full binary tree? (3marks)
iii. Define the term Recurrence Relation (3marks)
i. An empty string: “”
ii. Matching braces: “( )”
iii. OR W enclosed with matching braces: “( W )”
iv. Series of W enclosed in braces: “( W W)”
Write a C/C++/Java function that takes a string as a parameter then checks whether the string is a
W (6 Marks)
d) Solve the following Recurrence using the repeated substitution method (7marks)
QUESTION 3 (THREE)
(4marks)
ii. Provide a stage wise parse for the following data using the bubble sort algorithm
(i.e. how would the data look after every run) (4marks)
27 78 44 21 12 55 37
QUESTION 4 (FOUR)
a)
i. Explain the worst case of a binary search algorithm; be careful to contrast this with
the linear searching strategy
(5marks)
ii. Write short notes on Linked Lists data structures articulating the different types of
linked lists in the process (4maks)
b)
i. The factorial of a given number is thus defined:
ii. Carry out an analysis of the Insertion Sort Algorithm given below (7marks)
INSERTION-SORT(A)
1. For i 2 to lenth(A)
2. Key A[i]
3. //insert A[i] into the sorted sequence A[1……i-1]
4. j i-1
5. While j>0 and A[j]>key
6. A[j+1] A[j]
7. j j-i
8. A[j+1] key