Question: Please help with the following exercise: R={(p,q),(q,r),(r,q),(r,s),(s,s)} Represent R by its matrix (with the elements of {p,q,r,s} listed in the indicated order). (2 marks) Use

Please help with the following exercise:
Please help with the following exercise: R={(p,q),(q,r),(r,q),(r,s),(s,s)} Represent R by its matrix

R={(p,q),(q,r),(r,q),(r,s),(s,s)} Represent R by its matrix (with the elements of {p,q,r,s} listed in the indicated order). (2 marks) Use Warshall's algorithm to compute the transitive closure R of R. Show your working and the resulting relation R. (6 marks) (b) Design an algorithm in pseudocode (or any programming language of your choice) that, given any array A of n integers, returns 1 if there are A[i] and A[j] in A such that A[i]+A[j]=0; otherwise, the algorithm returns 0. Your algorithm must not change the given array and may only use a constant amount of additional space. (4 marks) What is the time complexity of your algorithm in terms of O notation? (1 mark) Now suppose the algorithm may change the array and use any amount of additional space. Describe an algorithm for this problem (without giving any code) that would run significantly faster than your original algorithm. What is the time complexity of this algorithm? (4 marks) (c) Use (i) breadth-first search and (ii) depth-first search to construct a spanning tree for the graph shown below, choosing vertex r as the root of your tree. (6 marks) Are the constructed trees isomorphic? Explain your

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!