Given a set of n distinct bolts and n corresponding nuts a


Given a set of n distinct bolts and n corresponding nuts, (a one-to-one correspondence exists between bolts and nuts), we want to find the correspondence between them. We are not allowed to directly compare two bolts or two nuts, but we can compare a bolt with a nut to see which one is bigger. Design an algorithm to find the matching pairs of bolts and nuts in time O(n2) for the worst case scenario. Your algorithm should have an expected running time of O(n log n).

Note: You can just explain your algorithm in English sentences; your answer does not have to be a pseudo-code.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Given a set of n distinct bolts and n corresponding nuts a
Reference No:- TGS02740439

Now Priced at $10 (50% Discount)

Recommended (97%)

Rated (4.9/5)