Question
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 ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started