二进制搜索树集

编程入门 行业动态 更新时间:2024-10-28 20:17:24
本文介绍了二进制搜索树集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

好的,首先,感谢所有帮助我解决同构问题的人 - 它终于有效了。现在,我的家庭作业的另一部分我遇到了麻烦:

OK, first of all, thanks to everyone who helped me out with my Isomorphism problem - it finally works. Now, the other part of my homework I''m having trouble with is this:

写一个集 class,使用二叉搜索树的关联迭代器。向每个节点添加指向父节点的链接。 Write an implementation of the set class, with associated iterators using a binary search tree. Add to each node a link to the parent node.

我不想在这里发布整个代码 - 大约有140行,这违反了我们的家庭作业政策。 基本上,看起来我的删除方法有问题;我将包括结构定义,类定义和我的两个删除方法定义:

I don''t want to post the whole code here - it''s about 140 lines, and it would violate our homework policy. Basically, it looks like my remove method is faulty; I''ll include the struct definition, the class definition, and my two remove method definitions:

展开 | 选择 | Wrap | 行号 推荐答案

果然,当我在我的驱动程序中停止使用.remove方法时,一切正常。 我还没有打扰添加迭代器 - 那会'是明天有趣的项目。 Sure enough, when I stop using the .remove method in my driver program, everything works just fine. I also have not yet bothered adding the iterators - that''ll be tomorrows fun project.

更新: 所以我错过了&书中代码中的几个地方。在适当的位置添加这些以插入,包含和删除后,每个东西都按预期工作。 :\ 我还是想保持这个线程活着,因为我可能需要一只手实现迭代器。 UPDATE: So I missed the & several places in the book''s code. After adding these in the appropriate places to insert, contains, and remove, every thing''s working as expected. :\ I''d still like to keep this thread alive, as I''ll probably need a hand implementing the iterator.

好的,我已经想到了++和 - 在我的迭代器上的算法(这是这个赋值中的主要问题),但我实际上在将迭代器(和const_iterator)插入到我的BSTreeSet类中时遇到了麻烦。这里是类定义: OK, I''ve thought of the algorithm for ++ and -- on my iterator (which was the main problem in this assignment), but I''m having trouble actually inserting the iterator (and const_iterator) into my BSTreeSet class. Here''s the class definitions: 展开 | 选择 | Wrap | 行号

更多推荐

二进制搜索树集

本文发布于:2023-11-29 01:32:37,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!