二进制搜索树集 [英] Binary Search Tree Set

查看:71
本文介绍了二进制搜索树集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 | 行号


这篇关于二进制搜索树集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆