Rawkhet Algorithms: Trade Queue
Technical piece! Rawkhet Pokemon gets about 100 orders a day, and prepares Pokemon in batches. At the end of each preparation batch, about 50 emails get sent out for collection. This poses an interesting problem – how do we handle the trade queue in the most efficient manner? Is first-come-first-serve, or FIFO (first-in-first-out) the best solution?
We actually use a custom data structure called a Priority Queue. This gives each order a “weight” or priority which we base off how large the order is (in terms of number of Pokemon to trade). When customers respond to get added to the queue, something like this happens:


