简体   繁体   English

在 Python 中使用 sortedcontainers 模拟 BST

[英]Using sortedcontainers in Python to emulate BST

I see some people recommending using SortedContainers as a drop in for some tree structures like Binary Trees like this reddit thread.我看到有些人推荐使用SortedContainers作为一些树结构的下降,比如像这个reddit线程这样的二叉树。 The documentation for SortedContainers mentions how it's more space efficient than typical implementations of Binary Trees SortedContainers的文档提到它如何比二叉树的典型实现更节省空间

Having said that, I don't actually see anyone talk about HOW to use it as such and I'd greatly appreciate if someone had a reference for how to emulate a BST or something of the like using Sortedcontainers or SortedCollection话虽如此,我实际上并没有看到有人谈论如何使用它,如果有人有关于如何使用 Sortedcontainers 或 SortedCollection 模拟 BST 或类似内容的参考,我将不胜感激

更新:在我的用例中,我不需要“使用 sortedcontainers 来模拟树结构 X”,因为它是引擎盖下的树结构 X

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM