\"Windows and Aisle Seats\" I travel on long flights often. Since I am not Donal
ID: 3761029 • Letter: #
Question
"Windows and Aisle Seats" I travel on long flights often. Since I am not Donald Trump (who is really rich), I need to travel in coach (economy) class often. Sometimes I get a good seat, and sometimes not. Seats have two distinct attributes for me: View, and Accessibility. Some seats have better view, and some are more accessible. Assume that for each seat, you are given view numeric value (suppose a double), and for accessibility also (also suppose a double). For example, for 5 seats, you may have the following data: [Seatl::view:4.3,accessibility:2.3, Seat2::view:2.4,accessibility:1.5, Seat3::view:9.0, accessibility:0.8, Seat4::view:5.9,accessibility:4.1, Seat5::view:6.3,accessibility:3.2]
[Not all seats are comparable, but you can see that SeatS is for sure better than Seatl.]
subjact
design and analysis algorithm
Explanation / Answer
Given that not all seats are comparable, we know that Views and Accesibility would depend on everyone's individual choice. But to derive an algorithm for this, we can add up both the values together for each Seat, and then these can be compared..
Algorithm:-
1. Sum up Views and Accesibility values for each seat (i).
2. Now in an Array Sum, which has added up values for each seat (i), sort this array based on the summing values.
3. The seat with the highest summed values is better than the ones with comparitively smaller values.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.