MIT 404 Main 2022
MIT 404 Main 2022
MIT 404 Main 2022
INSTRUCTIONS:
Answer Question ONE and any other TWO Questions.
a) The quicksort algorithm is one of the fastest sorting algorithms. Using pseudo
code, outline the steps for implementing it. [6 marks]
b) Show all steps in quicksort applied to the array 20 80 40 25 60 10 15 use 20 as
the pivot. [6 marks]
c) From the steps in 3b above, determine the time complexity function 𝑓(𝑛) and
the big O of 𝑓(𝑛). [4 marks]
d) Determine the best case, average case and worst case time complexity scenario.
[4 marks]
b
5 d
4 6
a 1 8 2 f
2 3
c e
10
Figure 1: Graph traversal
2|P age
MIT 404
c) In figure 1, let node a be the root, determine all the spanning trees of the graph
hence the minimum spanning tree. [6 marks]
d) Let A be the graph in figure 1. Write the adjacency matrix for A, Compute A.A
and discuss the meaning of the resulting figures [5 marks]
b) For the graph (figure 2), give one possible Depth First Search (DFS) traversal
starting from node 0 as the source. Note that the graph is directed.
3|P age