左右计数二叉树 [英] left and right count of a binary tree

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

问题描述



i想要计算二叉树节点的左右计数。



db结构是......



id_no | parent_no |安排

1 0 0

2 1 L

3 1 R

4 2 L



现在如果我输入1作为节点



左= 2且右= 1我必须得到。



严重需要代码...


i want to count the left and right count of node of a binary tree.

db structure is...

id_no | parent_no | placement
1 0 0
2 1 L
3 1 R
4 2 L

now if i input 1 as the node

Left = 2 and right = 1 i have to get.

need the code badly...

推荐答案

我们不做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



这不是一个特别困难的问题:它最多不会花费你半小时到一个小时!
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

This isn't a particularly difficult problem: it shoudln't take you more than half an hour to an hour at most!


致OriginalGriff先生



感谢您对我的家庭工作的评论。为了您的善意信息,这不是我的家庭作业。并感谢你没有解决我的问题。我自己做了。



任何方式解决了所有其他需要它的程序。



To Mr. OriginalGriff

Thanks for your comment about my "HOME WORK". for your kind information its not my home work. and thanks to you for not solving my problem. I did it myself.

any way solved program for all others who need it.

int Cr = 0;
private void pNode(string node)
        {
            string sql = "select * from biodata_master where parent_no='" + node + "'";

            DataTable dt = new DataTable();
            dt = obj.SelectData(sql);

            if (dt.Rows.Count == 1)
            {
                Cr = Cr + 1;
            }
            else if (dt.Rows.Count > 0)
            {
                Cr = Cr + 2;
                pNode(dt.Select("PLACEMENT='Left'")[0].ItemArray[0].ToString());
                pNode(dt.Select("PLACEMENT='Right'")[0].ItemArray[0].ToString());
            }
}







请向人们请求我的谦卑请求和你一样(极限专业人士)请不要通过说这些话来贬低像我这样的新手。请不要理睬我的话。



感谢你。




and please its my humble request to the people like you(Extreme Professionals) please do not demoralize the novices like me by saying these kind of words. Please don't take my word badly.

Thanking you.


这篇关于左右计数二叉树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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