当前位置:网站首页>C#二叉树结构定义、添加节点值
C#二叉树结构定义、添加节点值
2022-06-29 12:05:00 【黄昏和星空】
本文讲解C#二叉树结构定义、添加节点值
///
/// 二叉树的定义
///
public class BiTNode
{
public BiTNode() { }
public int data;//数据域
public BiTNode lchild;
public BiTNode rchild;
}
实际main程序测试
public const int MaxSize = 50;
static void Main(string[] args)
{
BiTNode T = new BiTNode() ;
int x=0;
//创建二叉树
T.data = 1;
T.lchild= new BiTNode();
T.lchild.data = 2;
T.rchild = new BiTNode();
T.rchild.data = 3;
T.lchild.rchild=new BiTNode();
T.lchild.rchild.data = 4;
T.lchild.rchild.lchild= new BiTNode();
T.lchild.rchild.lchild.data = 6;
T.rchild.rchild = new BiTNode();
T.rchild.rchild.data = 5;
Console.WriteLine(“先序遍历的值:”);
PreOrder(T);
Console.WriteLine();
Console.WriteLine(“中序遍历的值:”);
InOrder(T);
Console.WriteLine();
Console.WriteLine(“后序遍历的值:”);
PostOrder(T);
Console.WriteLine();
Console.WriteLine(“非递归中序遍历的值:”);
InOrder2(T);
Console.WriteLine();
Console.WriteLine(“层次遍历的值:”);
LevelOrder(T);
Console.ReadLine();
}

边栏推荐
- [comprehensive case] credit card virtual transaction identification
- 535. encryption and decryption of tinyurl: design a URL simplification system
- Go Senior Engineer required course | I sincerely suggest you listen to it. Don't miss it~
- nvtmpp
- Qt的信号与槽
- Syntax of gbase8s database incompatible with for update clause
- Gbase8s database select has order by Clause 6
- C#实现二叉树非递归中序遍历程序
- Proteus软件初学笔记
- AGCO AI frontier promotion (6.29)
猜你喜欢

Adjacency matrix and adjacency table structure of C # realization graph

MIT linear algebra Chinese Notes

倍福控制器连接松下EtherCAT伺服注意事项

Testing -- automated testing: about the unittest framework

How to calculate win/tai/loss in paired t-test

架构实战营第五模块课后作业

JVM之方法区

How can colleges and universities build future oriented smart campus based on cloud native? Full stack cloud native architecture vs traditional IT architecture

百度云盘不限速下载大文件(2021-11亲测有效)
![[leetcode] 14. Longest public prefix](/img/3b/3388ce8382ad5caaaf0a42488da2f9.png)
[leetcode] 14. Longest public prefix
随机推荐
How to install oracle19c in Centos8
【LeetCode】14、最长公共前缀
中职网络安全技能竞赛之应用服务漏洞扫描与利用(SSH私钥泄露)
huffman编码
推荐模型复现(四):多任务模型ESMM、MMOE
Gbase 8s extended external connection 1
推荐模型复现(一):熟悉Torch-RecHub框架与使用
[环境配置]PWC-Net
AES-128-CBC-Pkcs7Padding加密PHP实例
oracle 19c : change the user sys/system username pasword under Linux
Method area of JVM
对p值的理解
[Junzheng T31] decompression and packaging of read-only rootfs file system squashfs
How to fix ORA-01017:用户名/口令无效 登录拒绝
How to install oracle19c in Centos8
二十三、1-Bit数据的存储(延迟线/磁芯/DRAM/SRAM/磁带/磁盘/光盘/Flash SSD)
Recommended model reproduction (II): fine arrangement model deepfm, DIN
C#通过线索二叉树进行中序遍历输出
Syntax of gbase8s database incompatible with for update clause
缓存一致性,删除缓存,写入缓存,缓存击穿,缓存穿透,缓存雪崩