<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Daily on Time Friend</title><link>https://time-friend.com/en/tags/daily/</link><description>Recent content in Daily on Time Friend</description><generator>Hugo</generator><language>en-GB</language><lastBuildDate>Wed, 29 Jul 2026 15:15:07 +0800</lastBuildDate><atom:link href="https://time-friend.com/en/tags/daily/index.xml" rel="self" type="application/rss+xml"/><item><title>What is a Tensor in TensorFlow?</title><link>https://time-friend.com/en/archive/what-is-a-tensor-in-tensorflow/</link><pubDate>Fri, 18 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/what-is-a-tensor-in-tensorflow/</guid><description>&lt;h2 id="tensor"&gt;Tensor&lt;/h2&gt;
&lt;p&gt;The term &amp;ldquo;tensor&amp;rdquo; was first introduced by William Rowan Hamilton in 1846. Yes, that&amp;rsquo;s the Hamilton who invented quaternions:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://incomparable9527.coding.net/p/imageBed/d/imageBed/git/raw/master/643fca018187d79da1be1bc50f3beb7544c7ff56ffd50d0b4d332952034daa1b.png" alt="Figure 3"&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A Tensor is actually a multidimensional array&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The purpose of Tensor is to be able to create higher-dimensional matrices and vectors.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="https://incomparable9527.coding.net/p/imageBed/d/imageBed/git/raw/master/61f12309aef252eb15cb7e168026f7bab180ea4a8cca2726d0ae4454c6003ba6.png" alt="Figure 1"&gt;&lt;/p&gt;
&lt;h3 id="color-example"&gt;Color Example&lt;/h3&gt;
&lt;p&gt;Color image files (RGB) are generally processed into 3-d tensors, where each element in the 2d array represents a pixel, R represents Red, G represents Green, B represents Blue&lt;/p&gt;</description></item><item><title>Math - Relationship Between Data Structures, Programming Statements, Basic Algorithms and Mathematics (Notes)</title><link>https://time-friend.com/en/archive/math-relationship-between-data-structures-programming-statements-basic-algorithms-and-mathematics/</link><pubDate>Tue, 15 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-relationship-between-data-structures-programming-statements-basic-algorithms-and-mathematics/</guid><description>&lt;p&gt;Many people say data structures and algorithms cannot be counted as mathematics.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Different data structures are products of applying mathematical thinking in programming.
Each data structure has its own characteristics, helping us more conveniently implement certain specific mathematical models.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="data-structures"&gt;Data Structures&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Don&amp;rsquo;t underestimate these data structures, they are actually &amp;ldquo;models&amp;rdquo; for solving problems&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="array"&gt;Array&lt;/h3&gt;
&lt;p&gt;Characteristics: Can directly locate required data through index, suitable for random access. Often combined with loop statements to implement iterative methods, such as binary search, Fibonacci sequence, etc.&lt;/p&gt;</description></item><item><title>Math - Naive Bayes Classification Algorithm (Notes)</title><link>https://time-friend.com/en/archive/math-naive-bayes-classification-algorithm/</link><pubDate>Mon, 14 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-naive-bayes-classification-algorithm/</guid><description>&lt;h2 id="naive-bayes"&gt;Naive Bayes&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;ldquo;After updating our initial beliefs about something with objective new information, we get a new, improved belief.&amp;rdquo;
&amp;mdash;- Mathematician Thomas Bayes (Thomas Bayes, 1702～1761)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;When you cannot accurately know the essence of something, you can rely on how many events related to that specific essence appear to judge the probability of its essential attributes.&lt;/p&gt;
&lt;p&gt;The more events supporting a certain attribute occur, the greater the possibility that attribute holds.&lt;/p&gt;</description></item><item><title>Math - Probability, Joint Probability, Conditional Probability, Marginal Probability and Bayes' Theorem (Notes)</title><link>https://time-friend.com/en/archive/math-probability-joint-conditional-marginal-probability-and-bayes-theorem/</link><pubDate>Sun, 13 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-probability-joint-conditional-marginal-probability-and-bayes-theorem/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Formula symbol explanation: &lt;code&gt;P(A|B) is conditional probability of A given B&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="joint-probability"&gt;Joint Probability&lt;/h2&gt;
&lt;p&gt;Various explanations and descriptions for understanding:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Joint probability refers to probability containing multiple conditions where all conditions hold simultaneously, denoted as P(X=a,Y=b) or P(a,b), some books also habitually denote as P(ab), but I&amp;rsquo;m not used to this notation, so below uses comma-separated notation. Must note that all conditions hold simultaneously!&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Probability of intersection of two or more events&lt;/p&gt;</description></item><item><title>Math - Probability, Random Variables and Distributions (Notes)</title><link>https://time-friend.com/en/archive/math-probability-random-variables-and-distributions/</link><pubDate>Sat, 12 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-probability-random-variables-and-distributions/</guid><description>&lt;h2 id="random-variable"&gt;Random Variable&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Let the sample space of random experiment be S, X = X(e) is a real-valued single-valued function defined on sample space S. X = X(e) is called a random variable.&lt;/li&gt;
&lt;li&gt;Essentially a function about basic events, independent variable is basic event, dependent variable is function value.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="random-experiment"&gt;Random Experiment:&lt;/h3&gt;
&lt;p&gt;Satisfies:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;(1) Repeatability: Experiment can be repeated under same conditions;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(2) Knowability: Each experiment has more than one possible result, and all possible results of experiment can be clearly identified in advance;&lt;/p&gt;</description></item><item><title>Math - Tree Depth-First Search and Breadth-First Search (Notes)</title><link>https://time-friend.com/en/archive/math-tree-depth-first-search-and-breadth-first-search/</link><pubDate>Fri, 11 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-tree-depth-first-search-and-breadth-first-search/</guid><description>&lt;h2 id="how-to-use-recursion-and-stack-to-implement-depth-first-search"&gt;How to Use Recursion and Stack to Implement Depth-First Search?&lt;/h2&gt;
&lt;p&gt;The process of depth-first search is logically consistent with recursive calls.&lt;/p&gt;
&lt;h3 id="write-a-treenode-class-code-supporting-node-insertion"&gt;Write a TreeNode Class Code, Supporting Node Insertion&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;TreeNode&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;constructor&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;key&lt;/span&gt;){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;this&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;key&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;key&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;this&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;sons&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;insert&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;key&lt;/span&gt;){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;node&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;new&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;TreeNode&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;key&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;this&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;sons&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;push&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;node&lt;/span&gt;) 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;node&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="try-creating-a-tree"&gt;Try Creating a Tree&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;str&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;hello word&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;str2&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;abcdefg&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// Root node
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;root&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;new&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;TreeNode&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;root&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;createTree&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;str&lt;/span&gt;,&lt;span style="color:#a6e22e"&gt;root&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;createTree&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;str2&lt;/span&gt;,&lt;span style="color:#a6e22e"&gt;root&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;createTree&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;strs&lt;/span&gt;,&lt;span style="color:#a6e22e"&gt;parent&lt;/span&gt;){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;strs&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;length&lt;/span&gt; &lt;span style="color:#f92672"&gt;!==&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;found&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;parent&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;sons&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;find&lt;/span&gt;((&lt;span style="color:#a6e22e"&gt;item&lt;/span&gt;)=&amp;gt;&lt;span style="color:#a6e22e"&gt;item&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;key&lt;/span&gt; &lt;span style="color:#f92672"&gt;===&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;strs&lt;/span&gt;[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;found&lt;/span&gt;){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;newStrs&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;strs&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;slice&lt;/span&gt;(&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;createTree&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;newStrs&lt;/span&gt;,&lt;span style="color:#a6e22e"&gt;parent&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&lt;span style="color:#66d9ef"&gt;else&lt;/span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;node&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;parent&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;insert&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;strs&lt;/span&gt;[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;newStrs&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;strs&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;slice&lt;/span&gt;(&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;createTree&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;newStrs&lt;/span&gt;,&lt;span style="color:#a6e22e"&gt;node&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&lt;span style="color:#66d9ef"&gt;else&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;strs&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;length&lt;/span&gt; &lt;span style="color:#f92672"&gt;===&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;console&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;log&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;Creation complete&amp;#39;&lt;/span&gt;,&lt;span style="color:#a6e22e"&gt;root&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;root&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="start-depth-first-search"&gt;Start Depth-First Search&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// Use stack to implement depth-first search
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// General idea is to push all nodes into array, then take last one to process, delete while processing.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// Until none left
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;dfsByStack&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;root&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;stack&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; []; 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Create stack object, js uses array instead of stack, each element is TreeNode type
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stack&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;push&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;root&lt;/span&gt;); &lt;span style="color:#75715e"&gt;// Initialize, push root node
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;while&lt;/span&gt; (&lt;span style="color:#a6e22e"&gt;stack&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;length&lt;/span&gt;) { &lt;span style="color:#75715e"&gt;// As long as stack has nodes, continue
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Take out just pushed node
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;node&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;stack&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;pop&lt;/span&gt;(); &lt;span style="color:#75715e"&gt;// Pop top node of stack, get first node entered
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (&lt;span style="color:#a6e22e"&gt;node&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;sons&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;length&lt;/span&gt; &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Already reached leaf node, output
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;console&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;log&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;Already reached leaf node&amp;#39;&lt;/span&gt;,&lt;span style="color:#a6e22e"&gt;node&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;key&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; } &lt;span style="color:#66d9ef"&gt;else&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Non-leaf node, traverse each of its child nodes
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Note, here uses a temporary stack stackTemp
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// This is to maintain traversal order, consistent with recursive traversal order
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// If order not required, can directly push to stack
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;stackTemp&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; (&lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;index&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;; &lt;span style="color:#a6e22e"&gt;index&lt;/span&gt; &lt;span style="color:#f92672"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;node&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;sons&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;length&lt;/span&gt;; &lt;span style="color:#a6e22e"&gt;index&lt;/span&gt;&lt;span style="color:#f92672"&gt;++&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;son&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;node&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;sons&lt;/span&gt;[&lt;span style="color:#a6e22e"&gt;index&lt;/span&gt;];
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;console&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;log&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;son&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;key&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stackTemp&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;push&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;son&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Put each node into stack sorted
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Reverse order
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;while&lt;/span&gt; (&lt;span style="color:#a6e22e"&gt;stackTemp&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;length&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stack&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;push&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;stackTemp&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;pop&lt;/span&gt;());
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; } 
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="breadth-first-search-bfs"&gt;Breadth-First Search (BFS)&lt;/h2&gt;
&lt;p&gt;Breadth-First Search BFS (Breadth First Search) is also called width-first search. It is a strategy of expanding nodes that are generated first.&lt;/p&gt;</description></item><item><title>Math - Tree Concepts (Notes)</title><link>https://time-friend.com/en/archive/math-tree-concepts/</link><pubDate>Thu, 10 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-tree-concepts/</guid><description>&lt;h2 id="basic-concepts-of-trees"&gt;Basic Concepts of Trees&lt;/h2&gt;
&lt;p&gt;A tree is a data structure composed of nodes or vertices and edges (possibly nonlinear) that does not contain any cycles. A tree without nodes is called an empty (null or empty) tree. A non-empty tree includes a root node and (likely) multiple additional nodes, all nodes forming a multi-level hierarchical structure.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A tree is a special type of graph (graphs will be mentioned in subsequent articles).&lt;/p&gt;</description></item><item><title>Math - Dynamic Programming, Edit Distance Calculation (Notes)</title><link>https://time-friend.com/en/archive/math-dynamic-programming-edit-distance-calculation/</link><pubDate>Wed, 09 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-dynamic-programming-edit-distance-calculation/</guid><description>&lt;h2 id="dynamic-programming-dp"&gt;Dynamic Programming (DP)&lt;/h2&gt;
&lt;p&gt;Many people abbreviate it as DP. Dynamic programming needs to derive the optimal solution of the final problem through optimal solutions of subproblems. Therefore, this method particularly emphasizes the transfer relationships between subproblems. We usually call these transfer relationships between subproblems &lt;code&gt;state transfer&lt;/code&gt;, and call the expressions used to describe these state transfers &lt;code&gt;state transfer equations&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="edit-distance-levenshtein-distance"&gt;Edit Distance (Levenshtein Distance)&lt;/h2&gt;
&lt;p&gt;Proposed by Russian scientist Vladimir Levenshtein (graduated from Moscow State University&amp;rsquo;s Department of Mathematics and Mechanics) in 1965. He won the IEEE Richard W. Hamming Medal in 2006 for his contributions to error-correcting code theory and information theory.&lt;/p&gt;</description></item><item><title>Math - Combination, Solve Schedule Planning and Natural Language Processing (Notes)</title><link>https://time-friend.com/en/archive/math-combination-solve-schedule-planning-and-lottery/</link><pubDate>Tue, 08 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-combination-solve-schedule-planning-and-lottery/</guid><description>&lt;h2 id="combination"&gt;Combination&lt;/h2&gt;
&lt;p&gt;Combination is a mathematical term. Generally, selecting m (m≤n) elements from n different elements as a group is called a combination of m elements taken from n different elements. We call problems related to finding the number of combinations as combination problems.&lt;/p&gt;
&lt;p&gt;For the complete set of combinations for all m values, we can call it All Combination. For example, for the set {1, 2, 3}, the complete combination is {empty set, {1}, {2}, {3}, {1, 2}, {1,3} {2, 3}, {1, 2, 3}}.&lt;/p&gt;</description></item><item><title>Math - Permutation, Solve Tianji Horse Racing and Password Cracking Problems (Notes)</title><link>https://time-friend.com/en/archive/math-permutation-solve-tianji-horse-racing-and-password-cracking/</link><pubDate>Mon, 07 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-permutation-solve-tianji-horse-racing-and-password-cracking/</guid><description>&lt;h2 id="tianji-horse-racing-story"&gt;Tianji Horse Racing Story&lt;/h2&gt;
&lt;p&gt;Tianji was a famous general of Qi, often raced horses with King of Qi, but always lost, very unhappy. Sun Bin wanted to help Tianji. He divided these horses into upper, middle, lower three grades. He let Tianji use his lower grade horse to fight King&amp;rsquo;s upper grade horse, use upper grade horse to fight King&amp;rsquo;s middle grade horse, use middle grade horse to fight King&amp;rsquo;s lower grade horse. After three matches, Tianji only lost first match, won last two matches, finally won entire match with King.&lt;/p&gt;</description></item><item><title>Math - Recursion, Divide and Conquer, From Merge Sort to MapReduce (Notes)</title><link>https://time-friend.com/en/archive/math-recursion-divide-and-conquer-from-merge-sort-to-mapreduce/</link><pubDate>Sun, 06 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-recursion-divide-and-conquer-from-merge-sort-to-mapreduce/</guid><description>&lt;p&gt;Teacher Huang Shen&amp;rsquo;s title is really too good, can&amp;rsquo;t find better title to describe today&amp;rsquo;s learning content. Haha~&lt;/p&gt;
&lt;h2 id="divide-and-conquer-thinking-in-merge-sort"&gt;Divide and Conquer Thinking in Merge Sort&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Problem: Sort a pile of messy unordered numbers according to rules from small to large or large to small&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4 id="ordered-case"&gt;Ordered Case&lt;/h4&gt;
&lt;p&gt;Try merging ordered arrays {1, 2, 5, 8} and {3, 4, 6} process.
&lt;img src="https://incomparable9527.coding.net/p/imageBed/d/imageBed/git/raw/master/ba8272d5cbead0e8168ecf222e0ddc87bd2a089a7ffb236f5b6b9c38b435723d.png" alt="Figure 1"&gt;&lt;/p&gt;
&lt;h4 id="unordered-case"&gt;Unordered Case&lt;/h4&gt;
&lt;p&gt;Try to continuously simplify problem, i.e., continuously simplify sequence, until only 1 number remains. 1 number itself is ordered,&lt;/p&gt;</description></item><item><title>Math - Recursion, Decompose Complex Problems (Notes)</title><link>https://time-friend.com/en/archive/math-recursion-decompose-complex-problems/</link><pubDate>Sat, 05 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-recursion-decompose-complex-problems/</guid><description>&lt;h2 id="recursion-and-loops"&gt;Recursion and Loops&lt;/h2&gt;
&lt;p&gt;Theoretically all recursion can do, loops can achieve.&lt;/p&gt;
&lt;p&gt;Recursion and loops are actually implementations of iterative method, and in certain situations, their implementations can be converted to each other.&lt;/p&gt;
&lt;h2 id="why-use-recursion"&gt;Why Use Recursion&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Since recursive function value return process is consistent with loop-based iterative method, why not just use iterative method directly, why still use recursive mathematical thinking and programming methods?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="how-to-find-all-possible-summation-methods-under-limited-total"&gt;How to Find All Possible Summation Methods Under Limited Total?&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Assume there are four denominations of currency, 1 yuan, 2 yuan, 5 yuan and 10 yuan, want to reward someone 10 yuan, can reward 1 ten yuan note, or 10 one yuan notes, or 5 one yuan notes plus 1 five yuan note, etc. How many schemes total?&lt;/p&gt;</description></item><item><title>Math - Mathematical Induction, Inject Soul into Computer (Notes)</title><link>https://time-friend.com/en/archive/math-mathematical-induction-inject-soul-into-computer/</link><pubDate>Fri, 04 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-mathematical-induction-inject-soul-into-computer/</guid><description>&lt;h2 id="what-is-mathematical-induction"&gt;What is Mathematical Induction?&lt;/h2&gt;
&lt;p&gt;Wheat grain placement rule on chessboard is, first square one grain, second square two grains, and so on, each small square has double grains of previous small square, until 64 squares filled. You discover grids 1 to 8&amp;rsquo;s wheat quantities are: 1, 2, 4, 8, 16, 32, 64, 128.&lt;/p&gt;
&lt;h3 id="find-pattern"&gt;Find Pattern&lt;/h3&gt;
&lt;p&gt;&lt;img src="https://incomparable9527.coding.net/p/imageBed/d/imageBed/git/raw/master/873afd7eccb11857ce37c70086e24e186089ea2e8e93daf7ea8677ee5746460e.png" alt="Figure 9"&gt;&lt;/p&gt;
&lt;p&gt;For infinite sequence problems like this, we usually can use &lt;code&gt;Mathematical Induction&lt;/code&gt; to prove&lt;/p&gt;</description></item><item><title>Math - Iterative Method, Make Each Calculation Closer to Truth (Notes)</title><link>https://time-friend.com/en/archive/math-iterative-method-get-closer-to-truth/</link><pubDate>Thu, 03 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-iterative-method-get-closer-to-truth/</guid><description>&lt;h2 id="what-is-iterative-method"&gt;What is Iterative Method?&lt;/h2&gt;
&lt;p&gt;Continuously use old variable values to recursively calculate new variable values.&lt;/p&gt;
&lt;h3 id="short-story"&gt;Short Story:&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Ancient Indian King Shah loved chess, planned to heavily reward chess inventor Prime Minister Sissa Ben Dahir. This clever minister pointed at chessboard and said to king: &amp;ldquo;Your Majesty, I don&amp;rsquo;t want other rewards, please put one grain in first small square of this chessboard, two grains in second small square, four grains in third small square, and so on, each small square has double grains of previous small square, until 64 squares filled, then give all grains on chessboard to your servant me!&amp;rdquo; King thought it trivial, happily agreed. But, when started putting grains, king discovered, before reaching twentieth square, one bag of wheat already empty. Then, bag after bag of wheat put into chessboard squares, king quickly realized, even bringing all India&amp;rsquo;s grain, couldn&amp;rsquo;t fulfill promise to Dahir.&lt;/p&gt;</description></item><item><title>Math - Remainder and Hash Function (Notes)</title><link>https://time-friend.com/en/archive/math-remainder-and-hash-function/</link><pubDate>Wed, 02 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-remainder-and-hash-function/</guid><description>&lt;h2 id="remainder"&gt;Remainder&lt;/h2&gt;
&lt;h3 id="example-1"&gt;Example 1:&lt;/h3&gt;
&lt;p&gt;Today is Wednesday, you want to know what day it will be 50 days later, you can calculate like this, divide 50 by 7 (because a week has 7 days), remainder is 1, finally add one day to today, this way you can know 50 days later is Thursday&lt;/p&gt;
&lt;h3 id="example-2"&gt;Example 2:&lt;/h3&gt;
&lt;p&gt;If you want to display 1123 records, 10 per page, how to calculate total pages? I think you definitely divide 1123 by 10, finally get quotient 112, remainder 3, so your total pages is 112+1=113, and final remainder is extra data that can&amp;rsquo;t fill a page.&lt;/p&gt;</description></item><item><title>Math - Computer Origin Binary (Notes)</title><link>https://time-friend.com/en/archive/math-computer-origin-binary/</link><pubDate>Tue, 01 Sep 2020 00:00:00 +0000</pubDate><guid>https://time-friend.com/en/archive/math-computer-origin-binary/</guid><description>&lt;h2 id="computer-origin"&gt;Computer Origin&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Computer&amp;rsquo;s origin is binary counting method in mathematics&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="what-is-binary-counting-method"&gt;What is Binary Counting Method?&lt;/h2&gt;
&lt;h3 id="daily-decimal"&gt;Daily Decimal&lt;/h3&gt;
&lt;p&gt;Arabic numerals consist of 10 counting symbols from 0 to 9, and adopt carry system, every 10 carries one place, take 2871 as example&lt;/p&gt;
&lt;p&gt;&lt;img src="https://incomparable9527.coding.net/p/imageBed/d/imageBed/git/raw/master/294a1909e34794530f44814c77647d1aa7c7c6b487067889af4a1a85b3b857da.png" alt="Figure 7"&gt;&lt;/p&gt;
&lt;p&gt;Where ^ represents power or exponentiation operation. Decimal digit places (thousands, hundreds, tens, etc.) are all in form of 10^n. Need special attention, any non-zero number&amp;rsquo;s 0th power is 1. In this new representation, 10 is called decimal counting method&amp;rsquo;s &lt;code&gt;base&lt;/code&gt;.&lt;/p&gt;</description></item></channel></rss>