I have huge amount of data (>10000000) with type int with every new item I want to calculate the median (so I will have >1000000 medians). Should I maintain a sorted list and insert items into this list in order then calculate the median each time or should I insert then sort the list each time.
Also would a std::vector
be an appropriate data structure for this? or will another data structure give better complexity
Note: I can't use std::set
since there might be duplicates also If use std::multiset
finding median will increase complexity since I will loop from beginning until middle to get its value.