3 ms·
I guess a binary tree is not necessary. Just separate them in bricks by the first few digits, and sort them inside too. Then, just put all the bricks that start
by gus_massa 12y ago
I guess a binary tree is not necessary. Just separate them in bricks by the first few digits, and sort them inside too. Then, just put all the bricks that start with 1 in the kitchen, the bricks that start with 2 in the bedroom, ... People is fast scaning a few items and select the right brick from the vault.
(Disclaimer: I didn't try this at home.)
- bkjelden 12y agosome sort of hashtable/BST hybrid - where each entry in the table points to a BST, and the hash function just returns the first base-10 digit off of the bill.
- tempestn 12y agoCan you imagine actually trying to sort 100,000 bills by serial number? Even if you can sort a bill every 10 seconds continuously, which you obviously can't, it would be about 7 weeks of full time work. Radio stations tend to run contests for what, a few months? So your expected return is perhaps a few thousand dollars. I can't imagine many worse jobs.
- kragen 12y agoSee my comment above for a better complexity analysis of this task.