Leetcode - Tree - Binary Tree Traversal

中小公司无线组网实战:用一台H3C AC和普通三层交换,实现办公网AP统一管理 本文详细介绍了中小型企业如何利用H3C AC控制器与普通三层交换机实现无线AP统一管理的实战方案。通过VLAN规划、DHCP配置和AC控制器设置,构建经济高效的办公网络,解决信号覆盖和连接稳定性问题,特别适合50-200人规模的企业部署。 阅读详情

1、Binary Tree Preorder Traversal 

Given a binary tree, return the preorder traversal of its nodes' values.

For example:
Given binary tree {1,#,2,3},

   1
    \
     2
    /
   3

return [1,2,3].

Note: Recursive solution is trivial, could you do it iteratively?

/**
 * Definition for binary tree
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    vector<int> preorderTraversal(TreeNode *root) {
        vector<int> nodeValue;
        preorder(root, nodeValue);
        return nodeValue;
    }
    void preorder(TreeNode *root, vector<int> &nodeValue)
    {
        if(root==NULL)
            return;
        nodeValue.push_back(root->val);
        preorder(root->left, nodeValue);
        preorder(root->right, nodeValue);
    }
};
/**
 * Definition for binary tree
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    vector<int> preorderTraversal(TreeNode *root) {
        // 时间复杂度为O(n),空间复杂度为O(h)
        vector<int> nodeValue;
        if(root==NULL)
            return nodeValue;
        stack<TreeNode*> nodeStack;
        nodeStack.push(root);
        while(!nodeStack.empty())
        {
            root=nodeStack.top();
            nodeStack.pop();
            nodeValue.push_back(root->val);
            if(root->right!=NULL)
                nodeStack.push(root->right);
            if(root->left!=NULL)
                nodeStack.push(root->left);
        }
        return nodeValue;
    }
};


2、Binary Tree Inorder Traversal

Given a binary tree, return the inorder traversal of its nodes' values.

For example:
Given binary tree {1,#,2,3},

   1
    \
     2
    /
   3

return [1,3,2].

Note: Recursive solution is trivial, could you do it iteratively?

/**
 * Definition for binary tree
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    vector<int> inorderTraversal(TreeNode *root) {
        vector<int> nodeValue;
        inorder(root, nodeValue);
        return nodeValue;
    }
    void inorder(TreeNode *root, vector<int> &nodeValue)
    {
        if(root==NULL)
            return;
        inorder(root->left,nodeValue);
        nodeValue.push_back(root->val);
        inorder(root->right,nodeValue);
    }
};
/**
 * Definition for binary tree
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    vector<int> inorderTraversal(TreeNode *root) {
        vector<int> nodeValue;
        stack<TreeNode*> nodeStack;
        while(root!=NULL||!nodeStack.empty())
        {
            //运行到这儿,root不允许为之前出现过的结点,否则死循环
            while(root!=NULL)
            {
                nodeStack.push(root);
                root=root->left;
            }
            if(!nodeStack.empty())
            {
                root=nodeStack.top();
                nodeValue.push_back(root->val);
                nodeStack.pop();
                root=root->right;
            }
        }
        return nodeValue;
    }
};

3、Binary Tree Postorder Traversal 

Given a binary tree, return the postorder traversal of its nodes' values.

For example:
Given binary tree {1,#,2,3},

   1
    \
     2
    /
   3

return [3,2,1].

Note: Recursive solution is trivial, could you do it iteratively?

/**
 * Definition for binary tree
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    vector<int> postorderTraversal(TreeNode *root) {
        vector<int> nodeValue;
        postorder(root, nodeValue);
        return nodeValue;
    }
    void postorder(TreeNode *root, vector<int> &nodeValue)
    {
        if(root==NULL)
            return;
        postorder(root->left, nodeValue);
        postorder(root->right, nodeValue);
        nodeValue.push_back(root->val);
    }
};

/**
 * Definition for binary tree
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    vector<int> postorderTraversal(TreeNode *root) {
        vector<int> nodeValue;
        stack<TreeNode*> nodeStack;
        if(root!=NULL)
        {
            nodeStack.push(root);
            while(!nodeStack.empty())
            {
                root=nodeStack.top();
                nodeStack.pop();
                nodeValue.push_back(root->val);
                if(root->left!=NULL) nodeStack.push(root->left);
                if(root->right!=NULL) nodeStack.push(root->right);
            }
            reverse(nodeValue.begin(), nodeValue.end());
        }
        return nodeValue;
    }
};

4、Binary Tree Level Order Traversal 

Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).

For example:
Given binary tree {3,9,20,#,#,15,7},

    3
   / \
  9  20
    /  \
   15   7

return its level order traversal as:

[
  [3],
  [9,20],
  [15,7]
]
/**
 * Definition for binary tree
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    vector<vector<int> > levelOrder(TreeNode *root) {
        vector<vector<int> > path;
        vector<int> levelPath;
        if(root==NULL)
            return path;
        queue<TreeNode*> node_handling, node_waiting;
        node_waiting.push(root);
        while(!node_waiting.empty())
        {
            swap(node_handling,node_waiting);
            while(!node_handling.empty())
            {
                root=node_handling.front();
                node_handling.pop();
                levelPath.push_back(root->val);
                if(root->left!=NULL)node_waiting.push(root->left);
                if(root->right!=NULL)node_waiting.push(root->right);
            }
            path.push_back(levelPath);
            levelPath.clear();
        }
        return path;
    }
};


5、Binary Tree Level Order Traversal II

Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).

For example:
Given binary tree {3,9,20,#,#,15,7},

    3
   / \
  9  20
    /  \
   15   7

return its bottom-up level order traversal as:

[
  [15,7],
  [9,20],
  [3]
]
/**
 * Definition for binary tree
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    vector<vector<int> > levelOrderBottom(TreeNode *root) {
        vector<vector<int>> path;
        int depth=0;
        nLevelOrder(root, depth, path);
        reverse(path.begin(), path.end());
        return path;
    }
    void nLevelOrder(TreeNode *root, int depth, vector<vector<int>> &path)
    {
        if(root!=NULL)
        {
            if(depth>=path.size())
            {
                vector<int> temp{root->val};
                path.push_back(temp);
            }
            else
                path[depth].push_back(root->val);
            nLevelOrder(root->left, depth+1, path);
            nLevelOrder(root->right, depth+1, path);
        }
    }
};
/**
 * Definition for binary tree
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    vector<vector<int> > levelOrderBottom(TreeNode *root) {
        vector<vector<int>> path;
        vector<int> levelPath;
        if(root!=NULL)
        {
            queue<TreeNode*> node_handling, node_waiting;
            node_waiting.push(root);
            while(!node_waiting.empty())
            {
                swap(node_handling,node_waiting);
                while(!node_handling.empty())
                {
                    root=node_handling.front();
                    node_handling.pop();
                    levelPath.push_back(root->val);
                    if(root->left) node_waiting.push(root->left);
                    if(root->right) node_waiting.push(root->right);
                }
                
                path.push_back(levelPath);
                levelPath.clear();
            }
            reverse(path.begin(),path.end());
        }
        return path;
    }
};


6、Binary Tree Zigzag Level Order Traversal

Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).

For example:
Given binary tree {3,9,20,#,#,15,7},

    3
   / \
  9  20
    /  \
   15   7

return its zigzag level order traversal as:

[
  [3],
  [20,9],
  [15,7]
]
/**
 * Definition for binary tree
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    vector<vector<int> > zigzagLevelOrder(TreeNode *root) {
        vector<vector<int>> path;
        vector<int> levelPath;
        if(root!=NULL)
        {
            bool zigzag=false;
            queue<TreeNode*> node_handling, node_waiting;
            node_waiting.push(root);
            while(!node_waiting.empty())
            {
                swap(node_handling, node_waiting);
                while(!node_handling.empty())
                {
                    root=node_handling.front();
                    node_handling.pop();
                    levelPath.push_back(root->val);
                    if(root->left)node_waiting.push(root->left);
                    if(root->right)node_waiting.push(root->right);
                }
                if(zigzag)
                {
                    reverse(levelPath.begin(), levelPath.end());
                    zigzag=false;
                }
                else
                    zigzag=true;
                path.push_back(levelPath);
                levelPath.clear();
            }
        }
        return path;
    }
};






Yocto系列讲解[入门篇]36 - 编译arm虚拟机qemuarm 玩一下qemuarm,因为之前用的x86架构 阅读详情

相关推荐

用迅为RK3588开发板DIY无人机飞控:从电路设计到PID调参全记录

本文详细记录了使用迅为RK3588开发板DIY无人机飞控的全过程,从硬件选型、PCB设计到实时系统构建和PID调参。RK3588核心板凭借其强大的AI算力和丰富接口,成为高性能无人机控制解决方案的理想选择。文章还分享了视觉导航系统集成和实际飞行测试经验,为硬件爱好者提供实用参考。

weixin_29053577的博客 434

【LeetCode】103. Binary Tree Zigzag Level Order Traversal 解题报告

转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51471280Subject 出处:https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ Given a binary tree, return the zigzag level ord

crazy_jack 9869

使用VScode编译AMI代码

我现在了解到的和拿到的code,都是基于AMI的code,一般的编译AMI都需要搭配使用AMI的编译环境Veb,而Veb用到现在,一直都觉得有点卡顿,浏览代码的体验也比VScode差很多。在这之前还要,考虑设置TOOLS_DIR和EWKE_DIR的环境变量,因为在Veb中是可以通过设置自动设置的,但是VScode里面没用设置环境变量的选项。这里可以看出,Veb工具栏中的Build和Rebuild All的命令对应这里的make和make rebuild,也就是说Veb是调用此命令进行编译的。

Dodijd的博客 1881

LeetCode力扣之102. Binary Tree Level Order Traversal

Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \...

LeeWei 209

迅投miniQMT量化交易之【网格交易】的实现(25)——写在最后

和大家一起分享如何使用miniQMT实现我们自己的网格交易系统。如果您对量化交易感兴趣,欢迎一起交流。

tzzqn2008的专栏 829

pytorch转onnx转paddlepaddle

1.pt转onnx 可查看我之前的文章:https://blog.youkuaiyun.com/oyjwin/article/details/117778583?spm=1001.2014.3001.5501

oyjwin的博客 1461

Leetcode学习笔记:#1008. Construct Binary Search Tree from Preorder Traversal

Leetcode学习笔记:#1008. Construct Binary Search Tree from Preorder Traversal Return the root node of a binary search tree that matches the given preorder traversal. (Recall that a binary search tree is a ...

ccystewart的博客 231

MT4/MT5 第三代移动平均线(MetaTrader 指标)

第三代移动平均线(3G-MA)是传统MA指标的升级版本,通过"时滞压缩"算法将信号滞后降至理论极限(λ=2)。该指标在保留平滑性的同时,信号速度比EMA快1.5-2.3倍,适用于MT4/MT5平台。核心参数包括计算周期(默认34)、滞后压缩系数(2-10)和应用价位选择,支持斜率变色功能。安装简单,无需外部依赖,通过多周期共振可提升12-18%胜率。指标代码包含完整的MT4/MT5实现方案,采用双缓冲计算结构,通过相位前移算法抵消群延迟。风险提示:需配合其他技术指标和严格风控(≤2%账户

JanLEE 579

LeetCode-94. Binary Tree Inorder Traversal [C++][Java]

Given therootof a binary tree, returnthe inorder traversal of its nodes' values.

贫道绝缘子的博客 226

2. 第一个 SAP CDS View 源代码的详细解析:CDS View 和底层自动生成 SQL View 的关系讲解

笔者前一篇教程文章,带着大家在 ABAP 系统创建了一个最简单的基于sflight数据库表的 CDS View:本文对这简单的 14 行源代码背后的知识点进行详细讲解。CDS 全称是 Core Data Services,它是一种数据建模技术,帮助开发者以更直观和高层的方式去描述数据库中所需的数据结构。在一个典型的 SAP ABAP 开发场景里,CDS 经常被用来编写各种用于报表、接口或业务逻辑的数据视图。通常,这些视图包含一系列注解。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1024

PCIE总线及其PCIE SWITCH的使用

PCIe总线与PCI最大的区别在工作原理上,PCIe是采用点到点的串行方式进行传输的,被称为“串行PCI”,由于采用了串行方式传输使得其工作频率可以达到2.5Ghz,大大增加了传输速率,同时采用全双工的通信方式,使得其传输速度提高了一倍,每一个PCIe总线设备与外部通信时有四根数据总线,分别有两个RX和TX,两根用于发送,两根由于接收。PCIe switch中文翻译为PCIe开关或PCIe交换机,主要作用将PCIe设备互联,PCIe switch芯片与其设备的通信协议都是PCIe;

zxm8513优快云博客 4735

LeetCode - 107. Binary Tree Level Order Traversal II

题目 LeetCode - 107. Binary Tree Level Order Traversal II 题目链接 https://leetcode.com/problems/binary-tree-level-order-traversal-ii/ 参考博客 解题思路 此题是题102的变体,略过。 解题源码 /** * Definition for a binary tree node....

virgilshi的博客 158

Android 9.0 系统framework关于忘记开机锁屏密码进不去系统桌面清除锁屏密码问题的解决

在9.0的系统rom定制化开发中,在一些产品中带锁屏密码的功能中,系统默认是滑动解锁,但是客户会设置锁屏密码,在某些时候会 忘掉锁屏密码,导致需要进入恢复出厂设置然后才能进入系统桌面,这样就导致系统的保存的资料都丢失了,所以需要要求提供接口 在下拉状态栏中或者系统服务中在忘记锁屏密码后不恢复出厂设置的情况下,可以清除锁屏密码,接下来就来实现功能

安卓兼职framework和app工程师的博客 615

LeetCode力扣之103. Binary Tree Zigzag Level Order Traversal

Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary tree [...

LeeWei 223

深度学习工具包 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格式的压缩包

Binary Tree Zigzag Level Order Traversal - LeetCode

Binary Tree Zigzag Level Order Traversal - LeetCode 题目: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the nex

不要说话的博客 569

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

[LeetCode] Binary Tree Inorder Traversal

[Problem] Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2   / 3 return [1,3,2]. Note: Recursive solution is triv

1.02^365的成长裂变 3705

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

LeetCode 107. Binary Tree Level Order Traversal II

LeetCode 107. Binary Tree Level Order Traversal II Solution1:我的答案 比102那道题多了一行代码。。。 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeN...

Allenlzcoder的博客 286

LeetCode 力扣 145. 二叉树的后序遍历 binary tree postorder traversal

大家觉得写还可以,可以点赞、收藏、关注一下吧! 也可以到我的个人博客参观一下,估计近几年都会一直更新!和我做个朋友吧!https://motongxue.cn 文章目录145. 二叉树的后序遍历题目描述示例:进阶分析递归版迭代版提交结果 145. 二叉树的后序遍历 题目描述 给定一个二叉树,返回它的 后序 遍历。 示例: 输入: [1,null,2,3] 1 \ 2 / 3 输出: [3,2,1] 进阶 递归算法很简单,你可以通过迭代算法完成吗? 分析 递归

motongxue的博客 192

Leetcode: Binary Tree Level Order Traversal II

题目 https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/ 分析 和

博客已迁移至 http://chenzz.me 711

LeetCode 889. Construct Binary Tree from Preorder and Postorder Traversal

原题链接在这里:https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal/ 题目: Return any binary tree that matches the given preorder and postorder traversals. Values in the...

weixin_30888027的博客 92

LeetCode Binary Tree Inorder Traversal

不用递归来实现树的中序遍历。

DRFish 1392

[勇者闯LeetCode] 107. Binary Tree Level Order Traversal II

[勇者闯LeetCode] 107. Binary Tree Level Order Traversal IIDescription Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from l

fanguzhai的博客 232

LeetCode—103. Binary Tree Zigzag Level Order Traversal

LeetCode—103. Binary Tree Zigzag Level Order Traversal 题目 https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/description/ 之字形层序遍历二叉树。 思路及解法 因为昨天刚做过层序遍历二叉树的题102. Binary Tree Level ...

pnnngchg的博客 377

Binary Tree Preorder Traversal leetcode

Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. 二叉树的前序遍历,非递归的写法考的比较多,方法很

shiralwz的专栏 314

LeetCode力扣之107. Binary Tree Level Order Traversal II

Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20,null,null,15,7], ...

LeeWei 216

Leetcode 145. Binary Tree Postorder Traversal

Leetcode 145. Binary Tree Postorder Traversal 问题描述二叉树的遍历后根序遍历,也就是左右根的顺序访问。 分别提供以下方法以及python代码: 递归的方式 class Solution: def postorderTraversal(self, root): """ :type root: TreeNode ...

Za七杂⑧ 335
上一篇: Leetcode - Tree /Dynamic Programming- Unique Binary Search
下一篇: Leetcode - Tree - Balanced Binary Tree
JerkWisdom
博客等级 码龄14年 70粉丝 76原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值