由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - complexity of set operation?
相关主题
[合集] 如何得到一个指向STL元素的指针?大侠进来看看这个问题
关于那个经典的missing number的题 (转载)Why should i include .cpp instead of .h
[question] what is the time complexity of qsort in standard c libarary(GCC, more specifically)?用STL map的时候怎么自己定义大小比较的关系
STL iterator的疑问c++ 得最基本问题
如何把文件内容读到2D的vector里?make 时候遇到 undefined reference 怎么办?
一个小程序差点搞死了g++,怎么回事?问个c++的template的问题
弱弱的问问hash, hashtable? (转载)基本功不扎实,问个问题
说c++不难的欢迎来看看这个STL怎样同时重载()和< ?
相关话题的讨论汇总
话题: set话题: complexity话题: insertion话题: operation话题: nlogn
进入Programming版参与讨论
1 (共1页)
m***t
发帖数: 254
1
say if i want to add an element to a set, and if there is duplicate, i will
only want keep one copy, what is
the complexity for each insertion? log(n)? so if n elements insertion, nlogn
?
l***t
发帖数: 81
2
yes.

will
nlogn

【在 m***t 的大作中提到】
: say if i want to add an element to a set, and if there is duplicate, i will
: only want keep one copy, what is
: the complexity for each insertion? log(n)? so if n elements insertion, nlogn
: ?

m***t
发帖数: 254
3
what if i use hash?

【在 l***t 的大作中提到】
: yes.
:
: will
: nlogn

S*****n
发帖数: 227
4
then O(1) and O(n)

【在 m***t 的大作中提到】
: what if i use hash?
N********n
发帖数: 8363
5
Usually a set is implemented as a balanced tree. If you do frequent
set intersection and unioning then you may go with bit-vector.

will

【在 m***t 的大作中提到】
: say if i want to add an element to a set, and if there is duplicate, i will
: only want keep one copy, what is
: the complexity for each insertion? log(n)? so if n elements insertion, nlogn
: ?

l***t
发帖数: 81
6
In STL set is implemented by balanced binary tree.
If you use hash, then O(1).

【在 m***t 的大作中提到】
: what if i use hash?
1 (共1页)
进入Programming版参与讨论
相关主题
STL怎样同时重载()和< ?如何把文件内容读到2D的vector里?
一道C++面试编程题一个小程序差点搞死了g++,怎么回事?
有人能解释一下这段C++代码吗弱弱的问问hash, hashtable? (转载)
帮帮看看这段tree insertion说c++不难的欢迎来看看这个
[合集] 如何得到一个指向STL元素的指针?大侠进来看看这个问题
关于那个经典的missing number的题 (转载)Why should i include .cpp instead of .h
[question] what is the time complexity of qsort in standard c libarary(GCC, more specifically)?用STL map的时候怎么自己定义大小比较的关系
STL iterator的疑问c++ 得最基本问题
相关话题的讨论汇总
话题: set话题: complexity话题: insertion话题: operation话题: nlogn