Problem:
o A traveler flies to many cities (airports) in an unbroken chain of flights with no loops i.e never revisiting an airport.
o For every flight, she has a boarding pass with only a From (City) and To (City) printed on it but no date/time.
o At the end of her journey, she hands you all her boarding passes but they’re shuffled, so you don’t know the starting or the ending city.
Can you:
o Write logic or pseudocode to print her whole journey in sequence. It should print e.g. (Starting) City1 -> City2 ->….-> (Ending) CityX
o State the time complexity of your solution.
o you’re given a Set of BoardingPass objects as input.
o there could be as many as hundreds of thousands of unique cities/airports.
o memory is no concern (i.e. you have infinite memory!). Optimize for execution time (time complexity).