本文介绍了二进制搜索树集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,首先,感谢所有帮助我解决同构问题的人 - 它终于有效了。现在,我的家庭作业的另一部分我遇到了麻烦:
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 | 行号
更多推荐
二进制搜索树集
发布评论