Hello.
There are three tasks that imply one big:
- Implement a quick sort algorithm (made) .
- Implement a randomized quick sort algorithm (made) .
- Using the quick sort method to solve the following problem.
" Nuts and bolts ":
The unorganized carpenter has a mixed set of N nuts and N bolts. The goal is to find the matching pair of nuts and bolts. Each nut corresponds exactly to one bolt, and each bolt corresponds exactly to one nut. By connecting the nut and the bolt to each other, the carpenter can learn more from them (however, he cannot directly compare two nuts or two bolts).
Develop an algorithm for this task that uses an average of N log (N) comparisons.
I did the first two, but with an understanding of the third task I have problems:
- Initially, a single array should be passed to the method, or two?
- Should the method sort or look for the same values in two arrays (nut-bolt pairs)?
I would also be very grateful if I could chew on this task, as far as possible.
Thank.