Question: Q 3. (5 marks) Let A be an array contains n pair of integer values. Let two pairs (e, f) and (g, h) are symmetric

 Q 3. (5 marks) Let A be an array contains npair of integer values. Let two pairs (e, f) and (g, h)

Q 3. (5 marks) Let A be an array contains n pair of integer values. Let two pairs (e, f) and (g, h) are symmetric if g is equals to f and h is equals to e. Write pseudocode for an algorithm that decides whether a given pair of input array A of size n is symmetric. If pair in A is symmetric the algorithm must return the value true, otherwise it must return the value false. 0 0 1 1 1 0 1 30 10 1 15 0 1 10 30 0 15 0 33 5 18 33 30 18 Algorithm must return false if a single pair does not hold symmetric relation with any other pair in an array A. Suppose (x, y] is non-symmetric then the algorithm will return -1 or false. (a) (1 mark) Explain what the worst case for the algorithm is. (b) (4 marks) Compute the time complexity of the algorithm in the best case. You must give the order of the time complexity using big-Oh notation and you must explain how you computed the time complexity. Question 3: Explaination Example: Two pairs (e, f) and (g, h) are said to be symmetric if g is equal to fand e is equal to h. For example, (10, 20) and (20, 10) are symmetric. Given an array of pairs find all symmetric pairs in it. = Input: arr[] {{12, 21}, {31, 41}, {6, 11}, {41, 31}, {11, 6}} Output: Following pairs have symmetric pairs (31, 41) (6, 11)

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!