最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

如何实现一套?

SEO心得admin38浏览0评论
本文介绍了如何实现一套?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想实现一组C.它是确定使用链表,创造了SET的时候,还是应该使用其他方法?

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 needed).

请注意:如果我使用链表的方式,我可能有以下的复杂性对我的设置操作:

NOTE: If I use the Linked List approach, I will probably have the following complexities for Set my operations:

  • 初始化:O(1);
  • 破坏:O(N);
  • 插入:O(N);
  • 删除:O(N);
  • 联盟:O(N * M);
  • 十字路口:O(N * M);
  • 的区别:O(N * M);
  • ismember:O(N);
  • issubset:O(N * M);
  • setisequal:O(N * M);

O(N * M)似乎可能会有点变大特别是对庞大的数据...有没有执行我的设置方式更有效?

O(n*m) seems may be a little to big especially for huge data... Is there a way to implement my Set more efficient ?

推荐答案

我已经使用了红黑树在过去建立集。

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

下面是来自维基百科的文章时的复杂性。

Here are the time complexities from the Wikipedia article.

空间为O(n)搜索O(log n)的插入O(log n)的删除O(log n)的

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

发布评论

评论列表(0)

  1. 暂无评论