



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Instructions Answer any four questions Examiners: Dr. M. O Cinneide Mr. V. Ryan
Question 1 a) You are assigned the job of scheduling exams for the subjects S1,S2,S3,S4,S5,S6,S7,S8,S9 using the least number of time slots. The restriction is that a pair of exams which are taken by the same student cannot be scheduled into the same time slot. The following pairs of subjects have at least one student who is taking both exams: S1 and S2, S1 and S8, S2 and S3, S2 and S7, S2 and S8, S3 and S5, S3 and S6, S and S9, S4 and S8, S5 and S6, S5 and S9, S6 and S9, S7 and S8, S8 and S9.
Use a graph to model the problem. Use the Welsh-Powell algorithm to colour the graph, and deduce the minimum number of time slots and how the exams could be distributed over the time slots. [10 Marks]
b) Draw a loop-free connected graph whose vertices have the following degrees, or explain why no such graph exists : 1,1,1,2,3,4,5, [5 Marks]
c) What is the definition of the running time of a program being O(f(N ))? [3 Marks]
d) Show that O(logx n) = O(log (^) y n) where n represents the size of the input.
Note that log a b^ =
log c b log c a [7 Marks]
a) Consider the following graph. Test and decide if it is planar or not. If it is planar, verify Euler’s Formula for the graph. If it is non-planar, find a subgraph which is homeomorphic to either K (^) 3,3 or K 5.
[11 Marks]
b) Can a bipartite graph contain a cycle of odd length? Explain your answer. A correct yes/no answer without a proper explanation will yield zero marks. [4 Marks]
c) Define what is meant by the Travelling Salesman Problem? [2 Marks]
Why does the nearest neighbour heuristic not yield an optimal solution to this problem? Use an example to illustrate your answer. [2 Marks]
Discuss how this optimisation problem can be transformed to a decision problem. [4 Marks]
What is the key point (important aspect) about this transformation? [2 Marks]
a
b
c
d
e
f
g
h
a) Prove the following In any graph or multigraph, the number of vertices of odd degree is even. [7 Marks]
b) Outline Prim’s Algorithm in pseudocode. [2 Marks]
Using Prim’s algorithm, find the minimum spanning tree of the following graph. Start with node A. Your answer should demonstrate clearly that you have used the algorithm. An answer which gives the correct tree, but fails to demonstrate that the algorithm was used will attract zero marks. [6 Marks]
c) Describe the SUBSET-SUM Problem. [2 Marks]
Show that the SUBSET-SUM Problem is in the class NP. [3 Marks]
Explain what is meant by the problem SUBSET^ SUM^. [2 Marks]
Explain why SUBSET^ SUM^ is probably not in the class NP. [3 Marks]
a) Prove that the number of walks of length q from vertex i to vertex j in a graph G=(V,E) with adjacency matrix M is M q^ (i,j) [7 Marks]
b) Using Warshall's algorithm, find the reachability matrix of the following digraph. Your answer must clearly demonstrate that you used the algorithm.
[8 Marks]
c) Analyse the time complexity of the following (nonsensical) recursive code: Assume that n represents the input size.
typedef int Q[1000] ; void F(Q A, int n); { int i,x; if (n > 1) { for (i= 1; i<n ; i++) { if (A[i] > A[i+2]) { x = A[i]; A[i] = A[i+1]; A[i+1] = x; } } F(A,n-1); } }
Show all workings clearly for full marks [10 Marks]