How to implement a set?

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

    Since you already have a linked list implemented, the easiest is a skip list. If you want to use balanced trees, the easiest in my opinion is a treap. These are randomized data structures, but generally they are just as efficient as their deterministic counterparts, if not more (and a skip list can be made deterministic).

提交回复
热议问题