Data Structures
        Posted  
        
            by Phoenix
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Phoenix
        
        
        
        Published on 2010-03-16T13:47:11Z
        Indexed on 
            2010/03/16
            14:06 UTC
        
        
        Read the original article
        Hit count: 791
        
data-structures
There is a large stream of numbers coming in such as 5 6 7 2 3 1 2 3 .. What kind of data structure is suitable for this problem given the constraints that elements must be inserted in descending order and duplicates should be eliminated.
I am not looking for any code just ideas? I was thinking of a Self-Balancing BST where we could add the condition that all nodes < current node on left and all nodes > current node on right, this takes care of the duplicates .. but i don't think they are necessarily inserted in descending order. Any ideas what might be a better choice .. ofcourse it needs to be efficient time and space wise.
© Stack Overflow or respective owner