Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

=+5 How does HRM relate to efforts to increase innovation?

Answered: 1 week ago