Académique Documents
Professionnel Documents
Culture Documents
d. Explain the concept of Asymptotic Notation, indicating the commonly rr.O no,L6i#t.]
e. The recurrence equation for the time complexity of a sorting algorithm is:
( Cr, ifn=l
r(n)-l*G)* cyn, if n>L
Show that the time complexity of the algorithm is O (n log n) by solving the recurrence
equation.
(4 marks)
02.
a, compare and contrast linear search and binary search using examples.
(5 marks)
b. Discuss the use of Hash Functions and Hash Tables in searching when compared to
linear search and binary search.
(4 marks)
c. What is a collision in hashing? Name three techniques which avoid collisions.
(3 marks)
d. State the differences between Depth First Search (DFS) and Breath First Search (BFS)?
Page I of4
{"[
(2 marks)
e. Perform the DFS in the graph given in Figure 1. Show how you use a stack for
traversing the graph. Use node G as sta(ing point.
(6 marks)
03.
a. Draw the recursion tree for the execution of the r..*riw algorithm which finds the
factorial value of the number 6.
(2 marks)
b. Write a recursive algorithm to construct the Fibonacci series of a given number n and
comment on the time complexity of the algorithm.
(4 marks)
c. Explain the Divide and Conquer method in algorithm designing.
(2 marks)
d. Illustrate the Quick sort algorithm using the following set of unsorted numbers. Cleary
state the steps you followed. What can you say about the time complexity of the Quick
sort algorithm?
23 10 7 45 t6 86 50 2 31 18
What is a stable sorting algorithm? Give two algorithms which satisfu,ht, er"e{}il-r]
04.
Page2 of 4
4t
d. Algorithm for the Huffman codes (Algorithm 1) and a message with the percentage of
occurrences of each symbol in the message are given below. Apply Huffman Codes for
the given message and generate the Huffman tree. Hence find the codewords for the
symbols in the message.
(8 marks)
05.
Page 3 of4
7,
e. Find out the shortest path from vertex 1 to all remaining vertices for the graph in Figure
3 using Digikstra algorithm.
(8 marks)
06.
6 32 18 20 16 3 10 1 13 t2
(6 marks)
Compare and contrast the Quick sort and Heap sort algorithms'
(2 marks)
Page 4 of 4