频道栏目
首页 > 资讯 > C# > 正文

C#算法实现二叉树,单链表,反向链表,stack栈

10-07-11        来源:[db:作者]  
收藏   我要投稿

二叉查找树

// 二叉查找树节点 Binary search tree node

    public class BinarySearchTreeNode

    { public int key;// 二叉查找树节点的值

       public BinarySearchTreeNode left;// 二叉查找树节点的左子节点

       public BinarySearchTreeNode right;// 二叉查找树节点的右子节点

       /// 二叉查找树节点构造函数

       public BinarySearchTreeNode(int nodeValue)

       {   key = nodeValue;//nodeValue 节点的值

           left = null; right = null;

       }

       /// 插入节点

       public void InsertNode(BinarySearchTreeNode node)

       {   if(node.key > this.key)

           {  if(this.right == null)

              {   this.right = node;//node插入的节点

                  return;

              }

              else

                  this.right.InsertNode(node);

           }

           else

           {   if(this.left == null)

              {   this.left = node; return; }

              else

                  this.left.InsertNode(node);

           }

       }

       /// 二叉查找树查询

       public bool SearchKey(int searchValue)

       { if(this.key == searchValue)//searchValue需要查询的值

              return true;// 是否找到查询的值

           if(searchValue > this.key)

           {   if(this.right ==

相关TAG标签
上一篇:C#里加密解密标准函数示例
下一篇:c# 退出时加一个确认窗口
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站