CSC 804

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

FACULTY OF PHYSICAL SCIENCE

DEPARTMENT OF COMPUTER SCIENCE


SECOND SEMESTER EXAMINATION 2023/2024
CSC 804: ADVANCED ALGORITHMS
Instruction: Answer any seven (7) questions. TIME: 3HRS, CREDIT UNIT: 3

1. Consider these sort algorithms:


quick sort, bubble sort, and insertion sort.
(i) Explain how they work.
(ii) Compute the complexity of bubble sort and insertion sort.
(iii) Sort these numbers using quick sort algorithm:
8, 4, 15, 10, 2, 6, 14, 1, 3
2. Consider these search algorithms:
Linear search and Binary search.
(i) Explain how they work
(ii) Compute their complexity

3. (a) Let M and N be integers, and suppose F(M,N) is recursively defined by


1 , 𝑖𝑓 𝑀 = 0 𝑜𝑟 𝑀 ≥ 𝑁 ≥ 1
F (M, N) = {
𝐹(𝑀 − 1, 𝑁) + 𝐹(𝑀 − 1, 𝑁 − 1) 0, 𝑂𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒

Find:
(i) F (4, 2) (ii) F(1, 5) (iii) F(2, 4)
(iv) When is F(M, N) undefined?
3 (b) Show that the following are recursive
(i) factorial n
ii) Fibonacci (n)
4. (a) Suppose the Alphabet given below represents what constitutes a valid
arithmetic expression that can be typed on one line, in a form digestible by
computers.
∑ = {0 1 2 3 4 5 6 7 8 9 + − ∗ / ( )}

Show whether the following strings are good or not good. Give reasons to
support your answers.
(i) (3 + 5) + 6)
(ii) 2 (/ 8 + 9)
(iii) (3 + (4 -) 8 )
(iv) 2) – ( 4

4 (b) Judging from your answers in 4(a) above, what conclusion could you
make about the natural way of defining a valid arithmetic expression?
5. (i) Why is the use of heuristics desirable?
(ii) Using Towers of Hanoi Puzzle, define what is meant by combinatorial
problem
(iii) Show that the computational complexity of Towers of Hanoi is O(2n)
6. (a) Traveling salesman problem (TSP) is easy to characterise but difficult
to solve. Discuss with emphasis on its:
(i) meaning (ii) graph (iii) solution, using nearest neighbour heuristic
as well as exact algorithm.
(b) List five application areas of TSP
7. Computational problems can be categorised into four. Discuss
8. Explain the concept of divide – and – conquer, and greedy strategies in
algorithm design. Use binary search technique, and knapsack model to
illustrate respectively.
9. Discuss briefly the following data structures
(i) array (ii) linked list (iii) tree
10. Consider the following algorithm
ALGORITHM Enigma ([1. . 𝑛, 1. . 𝑛])
// Input: A Matrix A [1. . 𝑛, 1. . 𝑛] of real numbers
for i =1 to n-1 do
for j = i + 1 to n-1 do
if A [𝑖, 𝑗] <> A [𝑗, 𝑖 ]
return false
return true
(i) What does this algorithm do?
(ii) What is the basic operation?
(iii) How many times is the basic operation executed?
(iv) What is the efficiency of this algorithm?

You might also like