How to implement a set?

后端 未结 5 1302
别那么骄傲
别那么骄傲 2021-02-04 16:56

I want to implement a Set in C. Is it OK to use a linked list, when creating the SET, or should I use another approach ?

How do you usually implement your own set (if ne

5条回答
  •  耶瑟儿~
    2021-02-04 17:34

    std::set is often implemented as a red black tree: http://en.wikipedia.org/wiki/Red-black_tree

    This approach will give you much better complexity on all the listed operations.

提交回复
热议问题