首页 > 解决方案 > 在 Python 中使用 sortedcontainers 来模拟 BST

问题描述

我看到有些人推荐使用SortedContainers一些树结构,比如二叉树,就像这个reddit线程。SortedContainers的文档提到它比二叉树的典型实现更节省空间

话虽如此,我实际上并没有看到有人谈论如何使用它,如果有人对如何使用 Sortedcontainers 或 SortedCollection 模拟 BST 或类似的东西有参考,我将不胜感激

标签: pythonsortedcollectionsortedcontainers

解决方案


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


推荐阅读