Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help please!! I need help with this problem. no coding just math Consider a map

ID: 3766401 • Letter: H

Question

Help please!! I need help with this problem. no coding just math

Consider a map of the Brazilian rainforest with the Amazon River passing horizontally through the center. Along the southern bank of the river are m villages. In these villages are m different Indian tribes, which do not get along. Let T be the set of size m that contains all of these tribes, and let S be a function that maps each southern village to the Indian tribe living there. On the northern bank are m other villages, which are inhabited by the same m tribes. The members of one tribe, however, may not be directly across the river from other members of their tribe (i.e. the Nukak may inhabit the first village on the southern bank, but the other Nukak may be in the third village on the northern bank and directly across from them on the northern bank may be the Akuntsu). Let n be a function that maps each northern village to only one tribe in the set T. You want to connect as many villages on the southern bank as possible to villages on the northern bank with rope bridges, but the bridges can only connect members of the same tribe and can't cross each other. How would you determine the maximum number of tribes that can be reunited?

Explanation / Answer

This problem can be solved with O(n) time complexity. Here's how you can solve it

Suppose m tribes are : ts1, ts2, ts3......... (total m) which lives in v1,v2....... (total m) in random order in southern bank and tn1,tn2,tn3......(total m) lives in northern bank.

we can convert this into a set of village,tribe pair

for example : (v1,tn3,ts2) means tribe third from northern bank and tribe second from southern bank lives in village one.

Now, iterate through village by village

for village one to village m

if both northern and southern tribe are same for that village (example if set is like (v5, tn4, ts4))

increase count

at the end of loop, count will be the maximum number of tribes that can be reunited.