关闭。这个问题需要details or clarity .它目前不接受答案。
想改进这个问题?通过 editing this post 添加详细信息并澄清问题.
2年前关闭。
Improve this question
根据cplusplus.com , [set::find][2]
时间复杂度是对数大小,[find function in algorithm library][3]
大小是线性的。
set::find(item)
find(begin(set),end(set),item)
我想知道这两个
find
方法在时间复杂度方面表现不同。
最佳答案
std::find
只是一个线性搜索,因为它对迭代器没有任何假设。std::set::find
利用 set 的树结构来实现 log-fast 性能。
关于c++ - set::find 和 <algorithm> find 之间的性能差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59212201/