How to implement a set?

后端 未结 5 1244
别那么骄傲
别那么骄傲 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:44

    I have used Red-Black trees in the past to build sets.

    Here are the time complexities from the Wikipedia article.

    Space O(n)
    Search O(log n)
    Insert O(log n)
    Delete O(log n)

提交回复
热议问题