Not really a coding question, more of a how can I do this question, so no code snippet.
In my database, imagine a long list of unsorted numbers.
nums = [9, 12, 15, 18, 22, 100, 1 , 4, 3, 2]
This gives me a median of 10.5
But now imagine my list is much longer, [9, 12, 15, 18, 22, 100, 1 , 4, 3, 2, ......] And every day, I introduce a new number to this list x. The list is stored in a database and I want to avoid hitting the database to get all of this data and then calculating the median.
Are there any tricks where I don't have to call all of the data every day to calculate the median for today after a new number is introduced?
Thanks for any ideas!