Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume we have two arrays X[ ] and Y[ ] of n characters each, where X[ ] has n randomly ordered characters, while Y[ ]

Assume we have two arrays X[ ] and Y[ ] of n characters each, where X[ ] has n randomly ordered characters, while Y[ ] has exactly the same n characters but in different order. Your task is to find a way to group the cells of the array X[ ] and Y[ ]into pairs that hold the same character.
For example:
Input:
X[O, L, M, S, N, J, P, T, I, R, H, G]
Y[S, N, H, P, T, I, O, R, L, M, G, J]
Output:
X[0] with Y[6]
X[1] with Y[8]
X[2] with Y[9]
X[3] with Y[0]
… and so on
a) Using a brute-force approach, design an algorithm to solve this problem, and
analyze its complexity. (3+2 marks)
b) Design a more efficient algorithm to solve this problem (6 marks),
and analyze its complexity (3 marks) [Important instruction: Create an arbitrary
list of 7 characters in array X and their corresponding ones in array Y to provide
full explanation of how your proposed algorithm should work step by step] (6
marks)
c) Implement your efficient algorithm using Python (10 marks)
d) Prepare a brief report (250 words) comparing the two algorithms

Step by Step Solution

3.53 Rating (150 Votes )

There are 3 Steps involved in it

Step: 1

Solution a PSUEDO CODE This is a brute force algorithm with time complexity On2 It naively iterates ... 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

Social Statistics For A Diverse Society

Authors: Chava Frankfort Nachmias, Anna Leon Guerrero

7th Edition

148333354X, 978-1506352060, 1506352065, 978-1483359687, 1483359689, 978-1483333540

More Books

Students also viewed these Algorithms questions