(※)中序遍历线索二叉树和逆中序遍历线索二叉树

先序遍历线索二叉树 前面已经和大家介绍过"给线索二叉树加先序线索"的操作,这里我们再来讨论先序遍历线索二叉树的操作. 我们先来讨论该如何找到二叉树T中某结点的先序后继:根据先序遍历"根左右"的遍历顺序,如果该结点有左孩子,那么该结点的先序后继就是该结点的左孩子;如果该结点无左孩子且有右孩子,那么该结点的先序后继就是该结点的右孩子;如果该结点既无左孩子又无右孩子,那么该结点的先序后继为... 阅读详情

        在前面的博客中, 我们已经学习了给二叉树加中序线索的方法. 接下来我们来学习中序遍历线索二叉树的方法.

        首先, 我们需要找到二叉树T中第一个被中序遍历的结点: 根据中序遍历的算法逻辑, (※)也就是找到二叉树T的最左下结点. 下面的算法可定位到二叉树的最左下结点.

BiTreeNode* FirstNode(BiTreeNode* T)//在以T为根的子树中, 寻找最左下结点(中序遍历中第一个被访问的结点)
{
    if(T->LTag==1)//根节点的左子树为空
    {
        //那么第一个被中序遍历的结点就是根节点T
        return T;
    }
    else//T的左子树不空
    {
        while(T->LTag==0)//如果该结点的LTag==1, 则该结点的左子树为空, 也即找到以T为根的子树最左下的结点
        {
            T=T->LChild;
        }
        return T;
    }
}

        接着, 我们需要找到某结点在中序遍历序列下的后继结点: 如果该结点的RChild指针已被线索化, 那么该结点的右孩子就是要寻找的中序后继结点; 如果该结点的RChild结点未被线索化, 那么以该结点的右孩子为树根,寻找以该结点右孩子为树根的二叉树中第一个被中序遍历的结点.

BiTreeNode* NextNode(BiTreeNode* T)//在中序线索二叉树中找到T的后继结点
{
    if(T->RTag==1)//该结点的右孩子指针域已被线索化, 直接返回该结点的右孩子指针即可
    {
        return T->RChild;
    }
    else//该结点的右孩子指针域未被线索化
    {
        return Fi
c语言数据结构-------线索二叉树(中序为例) printf("第二层左节点数据:%d\n第二层右节点数据:%d\n", rootNode->left->data, rootNode->right->data);printf("第三层第一个节点右指针数据:%d\n第三层第二个节点右指针数据:%d\n", rootNode->left->right->data,printf("第四层第一个节点左指针数据:%d\n", rootNode->left->right->left->data);//if(node->ltag==0),保证其为结点。 阅读详情

相关推荐

数据结构05:树与二叉树[C++][线索二叉树:中序]

本篇博文含{线索化的基本原理与中序线索化的代码},由于模板字数限制,先序、后序线索化的代码会放在下篇整理~🥝🥝

weixin_42789937的博客 2953

二叉遍历树,逆中序遍历

//输入一个数列以0为结束标志,建立二叉遍历树,并对其进行逆中序遍历,释放空间,0代表null

平衡树的逆中序输出

建立存储数字的平衡树,并把树逆中序输出。 建立树步骤为插入数字,然后进行左右平衡,左右旋转。

LabVIEW通过ActiveX控件实现与三菱FX5U PLC的高效数据交互

本文详细介绍了如何利用LabVIEW的ActiveX控件,通过三菱官方MX Component工具包实现与FX5U PLC的高效数据交互。文章从环境配置、控件插入到实战代码解析,系统讲解了连接建立、数据读写及资源释放的全流程,并提供了关键的避坑指南,帮助工程师快速构建稳定可靠的上位机通讯系统。

weixin_29197051的博客 385

新手自己动手设置3D-slicer中文版(超详细图文)

3DSlicer是一个开源的免费软件,用于医学图像分析(包括配准和交互式分割)和可视化(包括3D渲染)以及用于图像引导治疗研究的软件平台。复制qm文件,粘贴于3D-slicer文件相关文件夹内,\bin\translations\。打开3dslicer,edit菜单下Application Settings,支持的操作系统:Linux,Mac OSX和Windows。本人英语太差,所以第一反应就是中文版,官网无中文版下载,下载后不能直接使用,必须要发布成qm文件;qm文件已经生成,位于ts文件同一文件夹。

linjianping513的博客 9913

如何编译RustDesk(Unbuntu 和Android版本)

备注:官方文档上,一边都是基于sciter,这个在后面已经不建议使用了,但是依然可以编译刚开始的时候看官方的文档,涉及的东西比较多,也搞的一头雾水,通过B站上一个视频,可以通过CI/CD来编译,以及act本地试试(最终放弃,大概需要下载大几十G的容器下来)。最终总算明确了方向,可以用自动化流水线来编译。直接看CI/CD的脚本文件文件在.github/workflows目录下,重点研究 bridge.yml 和flutter-build.yml 这两个文件。

lvronglee的专栏 2555

元数据管理:DataHub和OpenMetadata对比分析

DataHub和OpenMetadata都试图解决数据编目,搜索,发现,治理和质量方面的相同问题。这两种工具都是出于为需要支持大量数据源、团队和用例的大型组织解决这些问题而诞生的。尽管这些工具在发布历史和成熟度方面略有不同,但它们的功能存在显着重叠。

weixin_38030820的博客 6650

CorelDraw插件开发-Cdr插件-CPG插件-GMS插件-安装位置

文章目录1.gms格式插件2.cpg格式插件3.作者答疑   CorelDraw软件是一款使用非常广泛的矢量图形软件,系统本身提供了非常便利的二次开发环境,制作插件的格式有两种,一种是gms格式的脚本插件,另外一种是cpg格式dll插件。 1.gms格式插件   gms格式插件是使用微软的 VBA 技术,编写和调试都比较方便,从9的版本开始支持。   安装:把gms文件复制到程序所安装的目录 gms 下,一般在C:\Program Files\Corel\CorelDRAW Graphics Suite 1

插件开发 2785

Trimble RealWorks处理点云数据(三)之点云抽稀取样

Trimble RealWorks处理点云数据(三)之点云抽稀取样

yilvyangguang520的博客 2162

多尺度仿真软件:Copasi_(1).Copasi概述

Copasi(Complex Pathway Simulator)是一款开源的多尺度仿真软件,专为生物化学、系统生物学和合成生物学领域的研究人员设计。它不仅能够模拟细胞内和细胞间的生化反应网络,还能处理代谢途径、信号传导途径和基因调控网络等多种复杂系统。Copasi提供了用户友好的图形界面和强大的命令行接口,支持多种仿真算法和分析工具,使用户能够高效地进行模型构建、仿真和分析。Copasi允许用户创建自定义报告,以便生成特定格式的仿真结果。用户可以通过图形界面或命令行创建自定义报告。

kkchenjj的博客 872

OpenClaw部署太难?汉化版+中文社区+国产替代品,国内用户零门槛指南

OpenClaw作为GitHub 10万+星的开源AI助手平台,近期在国内AI圈备受关注 🌟 但部署难度和英文界面让很多用户望而却步。本文整理了针对国内用户的友好资源和简便替代方案,帮助国内用户零门槛上手AI助手工具 🚀

XiaoqiangClub的博客 5777

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

inori mmd 7z

楪祈的模型资源....................................................................................................................................................................................................................

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

上一篇: (※)给线索二叉树加线索
下一篇: 先序遍历线索二叉树
好梦成真Kevin
博客等级 码龄9年 727粉丝 479原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

好梦成真Kevin

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值