【算法总结】你真的掌握了二叉树的遍历嘛

【即插即用模块】注意力篇 | TGRS 2025 | CDFIM:通道+空间多尺度注意力,双模态特征融合增强,性能翻倍! C2DFF-Net提出了一种轻量级跨模态特征融合模块CDFIM,通过模态差异感知和多尺度深度滤波增强双模态互补信息。该模块采用通道-空间注意力协同机制,以极低计算成本(仅增加0.26M参数)提升多模态目标检测性能,在三个遥感数据集上平均提升mAP约1.7%。适用于无人机等边缘设备的实时检测任务,为跨模态融合提供高效解决方案。 阅读详情
  • 层次遍历顺序:[1 2 3 4 5 6]

  • 前序遍历顺序:[1 2 4 5 3 6]

  • 中序遍历顺序:[4 2 5 1 3 6]

  • 后序遍历顺序:[4 5 2 6 3 1]

层次遍历使用 BFS 实现,利用的就是 BFS 一层一层遍历的特性;而前序、中序、后序遍历利用了 DFS 实现。

前序、中序、后序遍只是在对节点访问的顺序有一点不同,其它都相同。

递归实现前序,中序,后序遍历


① 前序

1void dfs(TreeNode root) {

2    visit(root);

3    dfs(root.left);

4    dfs(root.right);

5}

② 中序

1void dfs(TreeNode root) {

2    dfs(root.left);

3    visit(root);

4    dfs(root.right);

5}

③ 后序

1void dfs(TreeNode root) {

2    dfs(root.left);

3    dfs(root.right);

4    visit(root);

5}

1. 非递归实现二叉树的前序遍历


144. Binary Tree Preorder Traversal (Medium)

Leetcode / 力扣:https://leetcode-cn.com/problems/binary-tree-preorder-traversal/description/

1class Solution {

2    //迭代

3    public List preorderTraversal(TreeNode root) {

4        List res = new ArrayList();

5        Stack stack = new Stack();

6        while(root!=null || !stack.empty()){

7            while(root!=null){

8                res.add(root.val); //先将节点加入结果队列

9                stack.push(root);  //不断将该节点左子树入栈

10                root = root.left;

11            }

12            root = stack.pop(); //栈顶节点出栈

13            root = root.right; //转向该节点右子树的左子树(下一个循环)

14        }

15        return res;

16    }

17

18}

2. 非递归实现二叉树的中序遍历


94. Binary Tree Inorder Traversal (Medium)

Leetcode / 力扣:https://leetcode-cn.com/problems/binary-tree-inorder-traversal/description/

1class Solution {

2    //迭代

3    public List preorderTraversal(TreeNode root) {

4        List res = new ArrayList();

5        Stack stack = new Stack();

6        while(root!=null || !stack.empty()){

7            while(root!=null){

8                stack.push(root);  //不断将该节点左子树入栈

9                root = root.left;

10            }

11            root = stack.pop(); //栈顶节点出栈

12            res.add(root.val); //将节点加入结果队列

13            root = root.right; //转向该节点右子树的左子树(下一个循环)

14        }

15        return res;

16    }

17}

3. 非递归实现二叉树的后序遍历


145. Binary Tree Postorder Traversal (Medium)

Leetcode / 力扣:https://leetcode-cn.com/problems/binary-tree-postorder-traversal/description/

前序遍历为 root -> left -> right,后序遍历为 left -> right -> root。可以修改前序遍历成为 root -> right -> left,那么这个顺序就和后序遍历正好相反。

1//修改前序遍历代码中,节点写入结果链表的代码:将插入队尾修改为插入队首

2//修改前序遍历代码中,每次先查看左节点再查看右节点的逻辑:变为先查看右节点再查看左节点

3class Solution {

4    public List postorderTraversal(TreeNode root) {

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级安卓工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Android移动开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
img

最后是今天给大家分享的一些独家干货:

Android学习PDF+架构视频+面试文档+源码笔记

【Android开发核心知识点笔记】

【Android思维脑图(技能树)】

【Android核心高级技术PDF文档,BAT大厂面试真题解析】

【Android高级架构视频学习资源】

.net/topics/618156601)

【Android开发核心知识点笔记】

[外链图片转存中…(img-o9ulFcKV-1710885654406)]

【Android思维脑图(技能树)】

[外链图片转存中…(img-WECey5NP-1710885654407)]

【Android核心高级技术PDF文档,BAT大厂面试真题解析】

[外链图片转存中…(img-3UfoQHmX-1710885654407)]

【Android高级架构视频学习资源】

OpenHands:开源AI智能体开发平台实战指南与架构解析 AI智能体(Agent)作为人工智能领域的关键技术,通过模拟人类的推理与行动循环,能够自主规划并执行复杂任务。其核心原理基于ReAct(Reasoning and Acting)框架,结合规划、工具使用与记忆系统,实现了从感知到决策的闭环。在软件工程领域,AI智能体的技术价值在于将自然语言指令转化为具体的开发操作,从而显著提升代码生成、测试编写和系统维护的效率。典型的应用场景包括自动化代码重构、智能文档生成以及持续集成流程的优化。本文聚焦于OpenHands这一开源AI驱动开发平台,它提供了完整的智能体SD 阅读详情

相关推荐

YOLOv11 网络结构详解:一文看懂 Backbone、Head、C3k2、SPPF 和 Detect 检测头

在使用 YOLOv11 进行目标检测时,我们经常会接触到或这样的模型配置文件。backbone和head分别是什么意思?ConvC3k2SPPFC2PSA这些模块分别起什么作用?P3/8、P4/16、P5/32 代表什么?为什么最后 Detect 要同时接收 3 个不同尺度的特征图?YOLOv11n、YOLOv11s、YOLOv11m、YOLOv11l、YOLOv11x 的区别在哪里?

learnerYC的博客 1809

【算法总结】你真的掌握了二叉树的遍历嘛(1)

最后这里放上我这段时间复习的资料,这个资料也是偶然一位朋友分享给我的,里面包含了腾讯、字节跳动、阿里、百度2019-2021面试真题解析,并且把每个技术点整理成了视频和PDF(知识脉络 + 诸多细节)。还有高级架构技术进阶脑图、高级进阶架构资料帮助大家学习提升进阶,也可以分享给身边好友一起学习。一起互勉~《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

2401_84121871的博客 974

新手必看!用FFmpeg一键合并ts文件的5种方法(含Windows/Mac终端命令)

本文详细介绍了使用FFmpeg合并TS视频文件的5种实用方法,涵盖Windows和Mac终端命令操作。从基础安装到进阶技巧,包括处理音频不同步、批量处理多个视频等场景,帮助用户轻松将m3u8分片视频合并为完整mp4文件,提升视频处理效率。

weixin_29065959的博客 557

【算法总结】你真的掌握了二叉树的遍历嘛(2)

前序遍历顺序:[1 2 4 5 3 6]中序遍历顺序:[4 2 5 1 3 6]后序遍历顺序:[4 5 2 6 3 1]层次遍历使用 BFS 实现,利用的就是 BFS 一层一层遍历的特性;而前序、中序、后序遍历利用了 DFS 实现。前序、中序、后序遍只是在对节点访问的顺序有一点不同,其它都相同。递归实现前序,中序,后序遍历① 前序5}② 中序5}③ 后序5}1. 非递归实现二叉树的前序遍历。

2301_82101470的博客 895

VS2015编译配置GDAL(图文并茂、超详细!!!)

文章目录一、GDAL介绍二、下载GDAL三、修改源代码四、工具命令提示符操作五、编译GDAL六、安装GDAL七、在VS2015的项目中配置GDAL八、添加环境变量九、测试是否配置成功 一、GDAL介绍 GDAL(Geospatial Data Abstraction Library)是一个在XMIT许可协议下的开源栅格空间数据转换库。它利用抽象数据模型来表达所支持的各种文件格式。它还有一系列命令行工具来进行数据转换和处理。OGR是GDAL项目的一个分支,功能与GDAL类似,只不过它提供对矢量数据的支持。因此

weixin_46196863的博客 3756

基于STM32F427的模拟SSI协议绝对式编码器位置反馈通信

基于STM32F427的模拟SSI协议绝对式编码器位置反馈通信

xeke997的博客 6064

【算法总结】你真的掌握了二叉树的遍历嘛,最新Android面试合集

UI这块知识是现今使用者最多的。当年火爆一时的Android入门培训,学会这小块知识就能随便找到不错的工作了。不过很显然现在远远不够了,拒绝无休止的CV,亲自去项目实战,读源码,研究原理吧!

2401_83946261的博客 772

核心组件大换血:Backbone与Neck魔改篇:YOLO26魔改Neck:引入BiFPN(双向特征金字塔),多尺度融合能力飙升

本文深入解析了YOLO26目标检测模型中Neck部分的优化策略,重点探讨了BiFPN(双向特征金字塔网络)的原理与实现。文章首先指出YOLO26原生FPN+PAN结构在多尺度特征融合上的局限性,特别是在小目标检测和边缘部署场景中的性能瓶颈。随后系统梳理了Neck网络的演进历程,从FPN、PANet到BiFPN和ASFF,详细对比了各架构的特点。核心部分展示了如何将BiFPN引入YOLO26,包括可学习权重融合、双向跨尺度连接等关键技术实现,并提供了PyTorch代码示例。本文为需要提升小目标检测性能或优化边

ZDQ58818的博客 246

【算法总结】你真的掌握了二叉树的遍历嘛,跨平台移动开发框架

② 中序 1void dfs(TreeNode root) { 2    dfs(root.left); 3    visit(root); 4    dfs(root.right); 5} ③ 后序 1void dfs(TreeNode root) { 2    dfs(root.left

m0_66264798的博客 84

第十二段:基于env的重用

现代芯片的验证通常分为两个层次, 一是模块级别( block level, 也称为IP级别、 unit级别) 验证, 二是芯片级别( 也称为SOC级别) 验证。 一个大的芯片在开发时, 是分成多个小的模块来开发的。 每个模块开发一套独立的验证环境, 通常每个模块有 一个专门的验证人员负责。 当在模块级别验证完成后, 需要做整个系统的验证。 假设某个系统分成了三个模块,如下图: 这三个模块在模块级别验证时, 分别有自己的driver和s...

年糕的博客 421

# YOLOv11改进系列 | 引入仓库自研C3k2_EIEM模块,Sobel边缘分支增强检测细节表达

文章摘要: YOLOv11-seg改进中提出的C3k2_EIEM模块通过引入边缘信息增强机制,显著提升了模型对轮廓和纹理的感知能力。该模块在保持原有C3k2结构的基础上,创新性地结合了Sobel边缘检测分支与常规卷积分支的双路特征融合。核心改进包括:(1)固定Sobel算子提供稳定的梯度响应;(2)并行处理边缘与纹理特征;(3)通过1x1卷积实现特征融合。实验显示,改进后模型参数量增加14.16%,计算量提升12.5%,但显著增强了在复杂边界场景下的分割精度。这种设计特别适用于需要精细轮廓识别的任务,如商品

qq_44224801的博客 95

【算法总结】你真的掌握了二叉树的遍历嘛(1),android开发游戏app

4    dfs(root.right); 5} ③ 后序 1void dfs(TreeNode root) { 2    dfs(root.left); 3    dfs(root.right); 4    visit(root); 5} 1. 非递归实现二叉树的前序遍历 144. Binary Tree Preor

m0_66264798的博客 2088

在 Esp32 摄像头上实现边缘脉冲 FOMO 物体检测

本文将详细介绍如何在 Esp32 摄像头上实现边缘脉冲 FOMO 物体检测,并提供实现源码

DT程序员的博客 705

视频隐私脱敏工程化:CSRT/KCF追踪算法在本地推理中的实现与边界

在短视频内容合规审查中,动态遮挡(Dynamic Masking)是高频且高耗时的环节。传统手动关键帧打码不仅效率低下,且在目标快速移动或遮挡时极易出现遮罩漂移。本文从计算机视觉工程角度,解析基于CSRT与KCF算法的目标追踪方案在视频隐私处理中的技术路径、性能权衡及落地实践。

Mysssone的博客 191

深度学习工具包 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")

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

上一篇: JavaScript之彻底搞懂DOM与BOM及其区别与用法,java前端开发
下一篇: Mac 安装 Node,大佬整理
普通网友
博客等级 码龄6年 3799粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值