Question: Problem 2 . On a distant planet, there is a group ( X ) of ( n ) aliens of type

Problem 2. On a distant planet, there is a group \( X \) of \( n \) aliens of type AlienX and a group \( Y \) of \( n \) aliens of type AlienY. Each alien in group \( X \) has a distinct IQ level. Similarly, each alien in group \( Y \) has a distinct IQ level. There is exactly one alien in group \( X \) who has the same IQ level with exactly one alien in group \( Y \). We call the two same IQ aliens "partners". We can make only the following comparison: choose an AlienX \( X[i]\) and an AlienY \( Y[j]\), ask them to look each other in the eye. They both originally are blue-eyed. If they have the exact same IQ level, their eyes will turn to green. If \( X[i]\) has a lower IQ level than \( Y[j]\) their eyes will turn to white, and if \( X[i]\) has higher IQ level than \( Y[j]\) their eyes will turn to black. This comparison can only be made between an AlienX and an AlienY, in other words, the eye-color change does not function between same type of aliens. Write an algorithm that will find the partner of each alien. Your algorithm should have an expected running time of \( O(n \log n)\).
Problem 2 . On a distant planet, there is a group

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 Programming Questions!