Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Question 3: Explaination Example: Two pairs (e, f) and (g, h) are said to be symmetric if g is equal to f and e

Java

image text in transcribed

Question 3:

Explaination Example:

Two pairs (e, f) and (g, h) are said to be symmetric if g is equal to f and 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)

please and question a and b

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 1 0 1 0 1 0 1 0 1 0 1 30 10 5 15 10 30 18 33 15 30 33 18 Algorithm must return false if a single pair does not hold symmetric relation with any other pair in an array A. Suppose [, 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

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_2

Step: 3

blur-text-image_3

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

Students also viewed these Databases questions

Question

=+2 Why did OBI create Centers of Excellence?

Answered: 1 week ago