0% found this document useful (0 votes)
5 views4 pages

Design $ Analysis of Algorithms 2023

The document is an examination paper for the Design and Analysis of Algorithms course at The East African University, consisting of five questions with specific instructions for answering. It covers topics such as complexity analysis, recursive algorithms, spanning trees, and algorithm time complexities. Students are required to demonstrate their understanding through explanations, comparisons, and pseudocode writing.

Uploaded by

teddyaseto2000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Design $ Analysis of Algorithms 2023

The document is an examination paper for the Design and Analysis of Algorithms course at The East African University, consisting of five questions with specific instructions for answering. It covers topics such as complexity analysis, recursive algorithms, spanning trees, and algorithm time complexities. Students are required to demonstrate their understanding through explanations, comparisons, and pseudocode writing.

Uploaded by

teddyaseto2000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

THE EAST AFRICAN UNIVERSITY (TEAU)

SCHOOL OF COMPUTER SCIENCE AND IT


DEPARTMENT OF COMPUTER SCIENCE
SEPTEMBER- DECEMBER 2023, MAIN EXAMINATION

COURSE : Design and Analysis of Algorithms


CODE : MAT 3203
TIME : 2 Hours

INSTRUCTIONS
1. The Paper is made up of FIVE (5) Questions, question ONE is compulsory plus any other
THREE questions.
2. Credit is given for legibility, clarity of expressions and use of relevant illustrations.
3. Clearly write your registration number on each answer sheet used.

DO NOT WRITE ANYWHERE ON THIS QUESTION PAPER

QUESTION ONE (24 MARKS)

a) Complexity analysis of an algorithm


i) Explain two complexities in prior analysis of an algorithm [4 marks]
ii) Compare priori analysis of an algorithm to posterior analysis [4 marks]
b) Asymptotic Algorithm Analysis aids computer scientists to choose the best algorithm
among many based on scientific limits of time and space using SEVEN fundamental
functions. Explain ANY FIVE such fundamental functions, draw a graph diagram to
summarize worst- case scenario notations of these functions [5 marks]
c) Use substitution method to derive the time complexity of the following algorithm [8
marks]

void test(int n)
{
if( n> 0)
{
for(i=0;i<n; i++)
{
Printf(“ %d ”, n);
}
test(n-1)
}
}

d) Define O-notation as used in algorithm analysis [3 marks]

QUESTION TWO (12 MARKS)


a) Using a relevant example, explain two key features of a recursive algorithm [4 marks]
b) Give the general plan for divide-and-conquer algorithms. [4 marks]
c) Distinguish between Depth First Search and Breath First searh [4 marks]

QUESTION Three (12 MARKS)

a) Describe Spanning tree and MST as used in algorithm design [4 marks]


b) Write the pseudocode to compute Huffman code [4 marks]
c) Road networks often have multiple pathways between destinations. Consider the below
logical representation of nodes on a road network with node A representing a source [4
marks]

QUESTION Four (12 MARKS)


a) Given the code snippets below, answer the following questions:
i) Compute the time complexity of the code snippet (Figure 1) above. Justify your
answer. [6 marks]
ii) The code below (Figure 2) is a modification of the code snippet above (Figure 1).
Will the code modification have an improved time complexity? If yes, what is the
new time complexity? Otherwise, justify your argument [6 marks]
QUESTION Five (12 MARKS)

b) Discuss what is meant by n-queen Problem [2 marks]


c) Determine the time and space complexity of the following algorithms, show all your
working [5 marks]

For (i=1; i<=n; i*=2)

Printf(“Edward”);

QUESTION Six (12 MARKS)


a) Using Java programming language, write a code snippet to declare an array that can hold
6 units done by a BscIT student, receive the name of the six units from the user and store
them in the array. [5 marks]
b) Determine the time complexity of the code above [5 marks]
c) Describe how Prim’s algorithm differ from Kruskal’s algorithm [2 marks]

You might also like