I have been thinking about this question for a while now.
Let's say there is a list s that contains books that people are selling. I have a book in s, and I want to trade for a book that is in s (something I don't have).
Each person in this scenario is selling one book in s, and also wants one book that is in s.
Is there an algorithm to find out the least number of trades required between people to get the book that I want (and give my book to people who want it)?
Please tell me if this seems confusing (because it probably is).
Thanks for answering the question!
EDIT: List s can grow at any time.