






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!







Semester 1 Examinations 2011/
Module Code: COMP
School: Science and Informatics
Programme Title: BSc (Honours) in Software Development – Year 4
Programme Code: KSDEV_8_Y
External Examiner(s): Ms. A. Meagher Internal Examiner(s): Dr J. Stynes
Instructions: Answer Question 1 and 2 others. Show all work.
Duration: 2 hours
Sitting: Winter 2011
Requirements for this examination:
Note to Candidates: Please check the Programme Title and the Module Title to ensure that you have received the correct examination paper. If in doubt please contact an Invigilator.
Q1 Provide a graph model for each of the following eight problems and then solve the problem. The solution MUST be obtained by using a graph theory result.
(a) There are 26 teams in a county league with 13 teams in each of 2 divisions. A league guideline said that each team’s 14-game schedule should include exactly 11 games against teams in its own division and 3 games against teams in the other division. Using a graph model, show that this guideline can not be satisfied. (6 marks) (b) How many different channels are needed for 6 TV stations, if no two stations within 150 kilometres of each other can operate on the same channel, and the distances in kilometres between the stations are as follows? (8 marks) 1 2 3 4 5 6 1 65 200 160 50 100 2 125 180 120 180 3 85 165 200 4^190 5^100
(c) John is in charge of assigning part-time jobs at a college. He has 25 student applications and there are 25 part-time jobs. Each applicant is qualified for at least 4 jobs but each job can be performed by at most 4 applicants. Can John assign all students to jobs for which they are qualified? (6 marks) (d) Below is the floor plan of a house showing the rooms and doors between rooms. Is it possible to start someplace (either in a room or outside) and walk through every door once and once only, and then end up where you started?
(6 marks)
Q3 (a) Solve the following recurrence relation: h 0 = 1 h 1 = 4 hn = 5 hn-1 - 6 hn-2, n > 1 (8 marks)
(b) Let T(n) be a function which models the time complexity of the function f. Write a recurrence relation for T(n). There is no need to solve the recurrence relation.
int f( int n ) { if ( n==1 ) return 0; else { int sum=0; for (int i=1; i<=n; i++) sum += ii ; return( f(n-2) + sum); } }* (4 marks)
(c) What are the complexity of the following algorithmic structures with respect to the problem size n. Assume that S is some operation in the order of O(1) and a is a constant greater than 1. (i) int x = 1; do { S ; x += a; } while ( x <= n );
(ii) int i = n; while ( i >1 ) { S; i /= 2; } (13 marks)
Q4 (a) Outline Prim’s algorithm to find a minimal spanning tree in a given graph. Apply it to the graph H (see Figure 3). Indicate clearly how the algorithm is used in finding the minimal spanning tree at each step. No marks will be awarded for a correct minimal spanning tree if it is not demonstrated clearly that the algorithm was used. (12 marks) (b) Find a Hamilton cycle in the graph K (Figure 4), or prove using the “3 rules” method that no Hamilton Cycle exists. You only need to consider the case where the edge (A,H) is in the Hamilton cycle being constructed. (13 marks)
Q5 (a) What are NP-complete problems? Give three examples. Why are they important in the study of algorithm complexity? (12 marks) (c) Do any one of the following: (i) Find the value of the largest row-sum in an n x n integer matrix A. For example, if the matrix A is 2 3 4 5 1 4 7 8 3 9 6 5 1 4 3 2 then the value we are looking for is 23 = 3+9+6+5. Devise a parallel algorithm to address this problem. Analyse the complexity of this algorithm. (ii) Merge Sort sorts an n -item list by splitting it into two lists of equal size ( n/2 ), which are each sorted using Merge Sort and then merged to produce the final sorted list. Calculate the time complexity, expressed in big-oh notation, of the Merge Sort algorithm. Assume that the merging operation to join two sorted lists, each of size n/2 , into a single list of size n is O(n). Why is it possible to assume that n is even when analysing the complexity of Merge Sort? (13 marks)
Figure 1 (graph G) NAME:_________________________
X
W