简体   繁体   English

有没有办法比 O(n) 更快地访问多集树中的单个节点(使用迭代器并在循环中计算迭代次数)? [等候接听]

[英]Is there a way to access single nodes from multiset tree faster than O(n)(using iterator and counting iterations in loop)? [on hold]

I've tried a lot of things to do it, but unsuccessful:( Maybe it'll be better if I write binary searching tree with some extra options myself? I have to keep elements in sorted order, to change single element and to get single element "by index".我已经尝试了很多事情,但没有成功:(如果我自己编写带有一些额外选项的二叉搜索树可能会更好?我必须保持元素排序,更改单个元素并获取单个元素“按索引”。

The std::multiset is fine. std::multiset 很好。 The find() function should have O(logn) with a worst case of O(n), as the std::multiset is implemented as a BST. find() function 应该有 O(logn),最坏的情况是 O(n),因为 std::multiset 是作为 BST 实现的。 Are you using the std namespace?你在使用 std 命名空间吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么在-O0而不是-O3中for循环中的访问比在有范围中的访问快? - Why access in a for loop is faster than access in a ranged-for in -O0 but not in -O3? 打印二叉树中所有节点的祖先。 我们可以在少于O(n ^ 2)的时间复杂度下做到吗? - Print ancestors of all nodes in a Binary Tree. Can we do it in less than O(n^2) time complexity? O(NlogN)算法运行速度比O(n)快......等等,什么? - O(NlogN) algorithm runs faster than O(n)… wait, what? for 循环或迭代器是遍历字符串的更快方法吗? - Is a for-loop or iterator a faster way to traverse a string? 对于循环迭代,OpenCV矩阵运算是否比简单运算更快? - Are OpenCV matrix operations faster than simple for loop iterations? 在未排序整数数组中查找最小元素的速度比O(n)还快? - Find minimum element in an array of unsorted integers faster than O (n)? 创建一个 C++ 预排序迭代器来为循环提供树节点 - Create a C++ preorder iterator to supply tree nodes to a loop 为什么使用 std::multiset 作为优先级队列比使用 std::priority_queue 更快? - Why is using a std::multiset as a priority queue faster than using a std::priority_queue? 计算树中的所有节点 - Counting all nodes in a tree 过滤迭代器循环(带提升)是否比内部带有 if 条件的经典 for 循环更快 - Are filtered iterator loops (with boost) faster than classical for loop with an if condition inside
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM