<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article">
 <front>
  <journal-meta>
   <journal-id journal-id-type="publisher-id">
    ojapps
   </journal-id>
   <journal-title-group>
    <journal-title>
     Open Journal of Applied Sciences
    </journal-title>
   </journal-title-group>
   <issn pub-type="epub">
    2165-3917
   </issn>
   <issn publication-format="print">
    2165-3925
   </issn>
   <publisher>
    <publisher-name>
     Scientific Research Publishing
    </publisher-name>
   </publisher>
  </journal-meta>
  <article-meta>
   <article-id pub-id-type="doi">
    10.4236/ojapps.2025.158156
   </article-id>
   <article-id pub-id-type="publisher-id">
    ojapps-144910
   </article-id>
   <article-categories>
    <subj-group subj-group-type="heading">
     <subject>
      Articles
     </subject>
    </subj-group>
    <subj-group subj-group-type="Discipline-v2">
     <subject>
      Biomedical 
     </subject>
     <subject>
       Life Sciences, Chemistry 
     </subject>
     <subject>
       Materials Science, Computer Science 
     </subject>
     <subject>
       Communications, Engineering, Physics 
     </subject>
     <subject>
       Mathematics
     </subject>
    </subj-group>
   </article-categories>
   <title-group>
    The Nullity Solution Algorithms for Trees
   </title-group>
   <contrib-group>
    <contrib contrib-type="author" xlink:type="simple">
     <name name-style="western">
      <surname>
       Chengzhi
      </surname>
      <given-names>
       Guo
      </given-names>
     </name>
    </contrib>
   </contrib-group> 
   <aff id="affnull">
    <addr-line>
     aSchool of Mathematics and Statistics, Qinghai Minzu University, Xining, China
    </addr-line> 
   </aff> 
   <pub-date pub-type="epub">
    <day>
     01
    </day> 
    <month>
     08
    </month>
    <year>
     2025
    </year>
   </pub-date> 
   <volume>
    15
   </volume> 
   <issue>
    08
   </issue>
   <fpage>
    2337
   </fpage>
   <lpage>
    2343
   </lpage>
   <history>
    <date date-type="received">
     <day>
      18,
     </day>
     <month>
      July
     </month>
     <year>
      2025
     </year>
    </date>
    <date date-type="published">
     <day>
      16,
     </day>
     <month>
      July
     </month>
     <year>
      2025
     </year> 
    </date> 
    <date date-type="accepted">
     <day>
      16,
     </day>
     <month>
      August
     </month>
     <year>
      2025
     </year> 
    </date>
   </history>
   <permissions>
    <copyright-statement>
     © Copyright 2014 by authors and Scientific Research Publishing Inc. 
    </copyright-statement>
    <copyright-year>
     2014
    </copyright-year>
    <license>
     <license-p>
      This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/
     </license-p>
    </license>
   </permissions>
   <abstract>
    This paper first discusses the storage structure of trees, selects a convenient storage method for solving the nullity of trees, and then applies the relationship between the maximum matching number of trees and the nullity to give an algorithm for calculating the maximum matching number and nullity of any tree.
   </abstract>
   <kwd-group> 
    <kwd>
     Nullity of Tree
    </kwd> 
    <kwd>
      Storage Structure
    </kwd> 
    <kwd>
      Maximum Matching Number
    </kwd> 
    <kwd>
      Algorithm
    </kwd>
   </kwd-group>
  </article-meta>
 </front>
 <body>
  <sec id="s1">
   <title>1. Introduction</title>
   <p>Consider 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       G 
     </mi> 
    </math> is a graph, and 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mi>
        V 
      </mi> 
      <mo stretchy="false">
        ( 
      </mo> 
      <mi>
        G 
      </mi> 
      <mo stretchy="false">
        ) 
      </mo> 
      <mo>
        = 
      </mo> 
      <mrow> 
       <mo>
         { 
       </mo> 
       <mrow> 
        <msub> 
         <mi>
           v 
         </mi> 
         <mn>
           1 
         </mn> 
        </msub> 
        <mo>
          , 
        </mo> 
        <mtext>
          ​ 
        </mtext> 
        <mtext>
          ​ 
        </mtext> 
        <mtext>
          ​ 
        </mtext> 
        <msub> 
         <mi>
           v 
         </mi> 
         <mn>
           2 
         </mn> 
        </msub> 
        <mo>
          , 
        </mo> 
        <mo>
          ⋯ 
        </mo> 
        <mo>
          , 
        </mo> 
        <msub> 
         <mi>
           v 
         </mi> 
         <mi>
           n 
         </mi> 
        </msub> 
       </mrow> 
       <mo>
         } 
       </mo> 
      </mrow> 
     </mrow> 
    </math> is its vertex set. The adjacency matrix of the graph 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       G 
     </mi> 
    </math> is denoted by 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       A 
     </mi> 
    </math>, which is an n-order matrix. When 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <msub> 
       <mi>
         v 
       </mi> 
       <mi>
         m 
       </mi> 
      </msub> 
     </mrow> 
    </math>is adjacent to 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <msub> 
       <mi>
         v 
       </mi> 
       <mi>
         n 
       </mi> 
      </msub> 
     </mrow> 
    </math>, 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <msub> 
       <mi>
         a 
       </mi> 
       <mrow> 
        <mi>
          m 
        </mi> 
        <mi>
          n 
        </mi> 
       </mrow> 
      </msub> 
      <mo>
        = 
      </mo> 
      <mn>
        1 
      </mn> 
     </mrow> 
    </math>, otherwise, 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <msub> 
       <mi>
         a 
       </mi> 
       <mrow> 
        <mi>
          m 
        </mi> 
        <mi>
          n 
        </mi> 
       </mrow> 
      </msub> 
      <mo>
        = 
      </mo> 
      <mn>
        0 
      </mn> 
     </mrow> 
    </math>.</p>
   <p>Definition 1.1. Let 
    <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mi>
        P 
      </mi> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mi>
         λ 
       </mi> 
       <mo>
         ) 
       </mo> 
      </mrow> 
     </mrow> 
    </math> be the characteristic polynomial of the adjacency matrix 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       A 
     </mi> 
    </math>, and the set of all roots (including duplicates) of 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mi>
        P 
      </mi> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mi>
         λ 
       </mi> 
       <mo>
         ) 
       </mo> 
      </mrow> 
     </mrow> 
    </math> is called the spectrum of the graph 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       G 
     </mi> 
    </math>. Among them, the multiplicity of the zero eigenvalue is called nullity of 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       G 
     </mi> 
    </math>, denoted by 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mi>
        η 
      </mi> 
      <mo stretchy="false">
        ( 
      </mo> 
      <mi>
        G 
      </mi> 
      <mo stretchy="false">
        ) 
      </mo> 
     </mrow> 
    </math>.</p>
   <p>The nullity of the graph 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       G 
     </mi> 
    </math> refers to the multiplicity of the zero characteristic root of its adjacency matrix. Obviously, 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mi>
        η 
      </mi> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mi>
         G 
       </mi> 
       <mo>
         ) 
       </mo> 
      </mrow> 
      <mo>
        = 
      </mo> 
      <mi>
        n 
      </mi> 
      <mo>
        − 
      </mo> 
      <mi>
        r 
      </mi> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mi>
         A 
       </mi> 
       <mo>
         ) 
       </mo> 
      </mrow> 
     </mrow> 
    </math>, in this case, 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       n 
     </mi> 
    </math> is the order of the graph 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       G 
     </mi> 
    </math> and 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mi>
        r 
      </mi> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mi>
         A 
       </mi> 
       <mo>
         ) 
       </mo> 
      </mrow> 
     </mrow> 
    </math> is the rank of the adjacency matrix 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       A 
     </mi> 
    </math>. When 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mi>
        η 
      </mi> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mi>
         G 
       </mi> 
       <mo>
         ) 
       </mo> 
      </mrow> 
      <mo>
        &gt; 
      </mo> 
      <mn>
        0 
      </mn> 
     </mrow> 
    </math>, i.e., 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       A 
     </mi> 
    </math> is a singular matrix, the graph 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       G 
     </mi> 
    </math> is called singular; otherwise, it is called nonsingular. Therefore, this problem has a good chemical background <xref ref-type="bibr" rid="scirp.144910-1">
     [1]
    </xref>-<xref ref-type="bibr" rid="scirp.144910-3">
     [3]
    </xref>. If a bipartite graph (corresponding to an alternating hydrocarbon) is singular, it means that the molecule represented by the graph is unstable; and this problem is also meaningful for nonsingular bipartite graphs (corresponding to non-alternating hydrocarbons).</p>
   <p>Definition 1.2. Given a bipartite graph 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       G 
     </mi> 
    </math>, in a subgraph of 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       M 
     </mi> 
    </math>, if any two edges in the edge set 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mrow> 
       <mo>
         { 
       </mo> 
       <mrow> 
        <msub> 
         <mi>
           e 
         </mi> 
         <mn>
           1 
         </mn> 
        </msub> 
        <mo>
          , 
        </mo> 
        <msub> 
         <mi>
           e 
         </mi> 
         <mn>
           2 
         </mn> 
        </msub> 
        <mo>
          , 
        </mo> 
        <mo>
          ⋯ 
        </mo> 
        <msub> 
         <mi>
           e 
         </mi> 
         <mi>
           m 
         </mi> 
        </msub> 
       </mrow> 
       <mo>
         } 
       </mo> 
      </mrow> 
     </mrow> 
    </math> of 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       M 
     </mi> 
    </math> are not incident to the same vertex, then 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       M 
     </mi> 
    </math> is called a matching. Selecting the largest subset of such edges is called the maximum matching of the graph 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       G 
     </mi> 
    </math>.</p>
   <p>Theorem 1.1. <xref ref-type="bibr" rid="scirp.144910-4">
     [4]
    </xref> Let 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       G 
     </mi> 
    </math> be a bipartite graph. If the length of every cycle in 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       G 
     </mi> 
    </math> is congruent to 2 modulo 4, 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mi>
        η 
      </mi> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mi>
         G 
       </mi> 
       <mo>
         ) 
       </mo> 
      </mrow> 
      <mo>
        = 
      </mo> 
      <mi>
        n 
      </mi> 
      <mo>
        − 
      </mo> 
      <mn>
        2 
      </mn> 
      <mi>
        q 
      </mi> 
     </mrow> 
    </math>, where 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       n 
     </mi> 
    </math> is the order of 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       G 
     </mi> 
    </math> and 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       q 
     </mi> 
    </math> is the maximum matching number.</p>
   <p>As a special type of bipartite graph, trees possess unique zero properties. Specifically, a tree with a perfect matching is referred to as a PM tree. As stated in Theorem 1.1:</p>
   <p>Theorem 1.2. <xref ref-type="bibr" rid="scirp.144910-5">
     [5]
    </xref> Let T be a tree, then 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mi>
        η 
      </mi> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mi>
         T 
       </mi> 
       <mo>
         ) 
       </mo> 
      </mrow> 
      <mo>
        = 
      </mo> 
      <mi>
        n 
      </mi> 
      <mo>
        − 
      </mo> 
      <mn>
        2 
      </mn> 
      <mi>
        q 
      </mi> 
     </mrow> 
    </math>, where 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       n 
     </mi> 
    </math> is the order of and 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
       q 
     </mi> 
    </math> is the maximum number of matches.</p>
  </sec><sec id="s2">
   <title>2. Design of Nullity Algorithm for Tree and Analysis of Algorithm Complexity</title>
   <sec id="s2_1">
    <title>2.1. Basic Method</title>
    <p>Based on Theorem 1.2, the following algorithm for calculating the nullity of a tree is introduced: First, calculate the maximum matching number 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        q 
      </mi> 
     </math> of the tree T by performing hierarchical priority storage and traversing the tree T in layer order to achieve matching and determine the maximum matching number. Then, using Theorem 1.2, the nullity value of the tree T is calculated.</p>
   </sec>
   <sec id="s2_2">
    <title>2.2. Storage Structure of Tree Vertices (Nodes)</title>
    <p>In order to facilitate the use of hierarchical traversal to achieve tree-to-tree T matching, the tree nodes contain the following five parts of information</p>
    <p>among</p>
    <p>Mark is the marker field, which is used to mark whether the tree nodes are matched or not with 0 and 1;</p>
    <p>Data is the data domain;</p>
    <p>Parent is a pointer to the parent node of that node;</p>
    <p>Child is a pointer to the child node that points to the node;</p>
    <p>Brother is a pointer to the brother node of the node.</p>
   </sec>
   <sec id="s2_3">
    <title>2.3. Nullity Algorithm for Tree</title>
    <p>The basic steps are:</p>
    <p>1) Build a tree T with n vertices, matching set 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         M 
       </mi> 
       <mo>
         = 
       </mo> 
       <mi>
         φ 
       </mi> 
      </mrow> 
     </math> and vertex 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         S 
       </mi> 
       <mo>
         = 
       </mo> 
       <mi>
         φ 
       </mi> 
      </mrow> 
     </math>;</p>
    <p>2) Starting with any vertex in tree T, fix this vertex as the initial vertex v<sub>0</sub>. The hierarchical classification of tree T proceeds as follows: Vertex v<sub>0</sub> is designated as Level 0. After removing v<sub>0</sub>, adjacent vertices are classified as Level 1. Subsequently, vertices from Level 1 are removed and their adjacent vertices form Level 2, and so forth. Through this iterative process, all vertices in tree T can be systematically categorized into levels 0, 1, ..., up to Level P. Create a tree T with n vertices, a matching set, and a vertex set;</p>
    <p>3) Select a vertex 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          v 
        </mi> 
        <mrow> 
         <mi>
           p 
         </mi> 
         <mn>
           1 
         </mn> 
        </mrow> 
       </msub> 
      </mrow> 
     </math> in level P, match 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          v 
        </mi> 
        <mrow> 
         <mi>
           p 
         </mi> 
         <mn>
           1 
         </mn> 
        </mrow> 
       </msub> 
      </mrow> 
     </math> with its parent node, mark parent node of 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          v 
        </mi> 
        <mrow> 
         <mi>
           p 
         </mi> 
         <mn>
           1 
         </mn> 
        </mrow> 
       </msub> 
      </mrow> 
     </math> and add it to the vertex set S, and add its matching edge to the matching set M. The sibling nodes of vertex 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          v 
        </mi> 
        <mrow> 
         <mi>
           p 
         </mi> 
         <mn>
           1 
         </mn> 
        </mrow> 
       </msub> 
      </mrow> 
     </math> do not participate in the matching with its parent node. Select other vertices in level P and repeat the above matching process;</p>
    <p>4) Select a vertex in level P-1 and repeat step (3) until all vertices in level 0 have been matched;</p>
    <p>5) Count the number of edges that match the set, i.e. the maximum number of matches in the tree T;</p>
    <p>6) Using Theorem 1.2, the zero value of a tree T is calculated by using the relationship between the maximum matching number of a tree and nullity.</p>
    <p>Then one can obtain nullity algorithm for tree as Algorithm 2.1.</p>
    <p>CBTree *bt; //Define a tree bt</p>
    <p>Zero=0; //Zero represents its nullity, and it is initialized</p>
    <p>Vertices=0; //Vertices represents the number of vertices in tree T, and it is initialized</p>
    <p>MatchNum=0; //MatchNum represents the maximum matching number of tree T, and it is initialized</p>
    <p>bt=CreateCBTree("A(B(D(,E(H,F)),C(G(I(,J(,K))))))"); //Call the constructor of tree T</p>
    <p>preorder(bt, &amp;MatchNum, &amp;Vertices); //Call the function to find the maximum matching number of the tree T</p>
    <p>Zero=Nullity( &amp;MatchNum, Vertices); //Call the nullity function of the computation tree T</p>
    <p>// Result output</p>
    <p>printf("the number of vertices in tree T: %d",Vertices);</p>
    <p>printf("the maximum matching number of tree T: %d",MatchNum);</p>
    <p>printf("nullity of tree T: %d",Zero);</p>
    <p>}</p>
    <p>The sub-functions are as follows:</p>
    <p>1:Define the storage structure of a tree</p>
    <p>typedef struct cbnode</p>
    <p>{ char data;</p>
    <p>int mark;</p>
    <p>struct cbnode *child;</p>
    <p>struct cbnode *brother;</p>
    <p>struct cbnode *parent;</p>
    <p>} CBTree;</p>
    <p>2:Create tree T using a generalized list</p>
    <p>CBTree *CreateCBTree(char *str)</p>
    <p>{</p>
    <p>top= -1, k=0, j=0;</p>
    <p>x=NULL;</p>
    <p>ch=str[j];</p>
    <p>while(ch!='0') //Create tree</p>
    <p>{</p>
    <p>//Convert the tree represented in the form of a generalized list to a layer-first storage format and create a tree T using the generalized list</p>
    <p>switch(ch)</p>
    <p>{</p>
    <p>case '(':top++;st[top]=p;k=1;break;</p>
    <p>case ')':top--;break;</p>
    <p>case ',':k=2;break;</p>
    <p>default: //Store the nodes of the tree (create tree T)</p>
    <p>p=(CBTree*)malloc(sizeof(CBTree));</p>
    <p>p-&gt;data=ch; //Store the nodes of the tree</p>
    <p>p-&gt;mark=0; //Assign initial values to the matching markers</p>
    <p>p-&gt;child=p-&gt;brother=NULL;</p>
    <p>p-&gt;parent=NULL;</p>
    <p>if(x==NULL)</p>
    <p>x=p;</p>
    <p>else</p>
    <p>{</p>
    <p>switch(k)</p>
    <p>{</p>
    <p>case 1:st[top]-&gt;child=p;break;</p>
    <p>case 2:st[top]-&gt;brother=p;break;</p>
    <p>}</p>
    <p>}</p>
    <p>}</p>
    <p>j=j+1;</p>
    <p>ch=str[j];</p>
    <p>} //Complete the creation of tree T</p>
    <p>return x; //Return the stored tree T</p>
    <p>}</p>
    <p>3:erform maximum matching operation on tree T</p>
    <p>void preorder(CBTree *p, int *N, int *vertices)</p>
    <p>{</p>
    <p>CBTree *str[MaxSize]; //Used to record the order in which vertices are visited during the layer-by-layer traversal of tree T</p>
    <p>CBTree *s1[MaxSize],*s2[MaxSize]; //Dual-stack implementation for tree matching</p>
    <p>CBTree *m;</p>
    <p>int top1=-1; int top2=-1; int top=-1; //Initialize the top pointer of the stack</p>
    <p>top1++;</p>
    <p>s1[top1]=p;</p>
    <p>while(top1!=-1||top2!=-1)</p>
    <p>{ while(top1!=-1)</p>
    <p>{top++;</p>
    <p>str[top]=s1[top1]; //Implement the storage of vertices of tree T in layers</p>
    <p>if(s1[top1]-&gt;child!=NULL) //Perform level-order traversal on the tree</p>
    <p>{</p>
    <p>top2++;</p>
    <p>s2[top2]=s1[top1]-&gt;child;</p>
    <p>m=s2[top2];</p>
    <p>m-&gt;parent=s1[top1];</p>
    <p>}</p>
    <p>while(m-&gt;brother!=NULL) //When using sibling nodes in the same layer, push its sibling nodes onto the stack before its child nodes.</p>
    <p>{ top2++;</p>
    <p>s2[top2]=m-&gt;brother; m-&gt;brother-&gt;parent=s1[top1]; //Push the brother node onto the stack</p>
    <p>m=m-&gt;brother; //Search for the next brother node</p>
    <p>}</p>
    <p>}</p>
    <p>top1--;}</p>
    <p>while(top2!=-1) //Use a double stack for data exchange to complete the level-order traversal of the tree.</p>
    <p>{ top1++;</p>
    <p>s1[top1]=s2[top2];</p>
    <p>top2--;}</p>
    <p>} //The traversal of the tree in layers has ended</p>
    <p>int i=0,num;</p>
    <p>num=top+1;</p>
    <p>//Calculate the maximum matching of tree T</p>
    <p>while(top!=-1)</p>
    <p>{if(str[top]-&gt;mark==0&amp;&amp; str[top]-&gt;parent-&gt;mark==0)</p>
    <p>{ //Determine whether a node can match its parent nodes</p>
    <p>str[top]-&gt;parent-&gt;mark=1; //Match successful</p>
    <p>i++; }</p>
    <p>top--; }//The process of computing the maximum matching of tree T has ended</p>
    <p>*N=i; //Maximum matching number of tree T</p>
    <p>*vertices=num; //The number of vertices in tree T</p>
    <p>}</p>
    <p>4:Calculate the nullity of tree T</p>
    <p>int Nullity(int *n, int num)</p>
    <p>{ return num-2*(*n); //Calculate the nullity of tree T}</p>
   </sec>
   <sec id="s2_4">
    <title>2.4. Algorithm Complexity Analysis</title>
    <p>This algorithm first stores the vertices in the tree T (containing n vertices) in a top-down and left-right order in a layer-first manner, and then matches the last vertex with its parent vertices one by one. Therefore, the maximum running time of this algorithm to complete the maximum matching is n − 1, its time complexity is O(n) and memory complexity is O(n). Theorem 1.2 clarifies the relationship between a tree’s maximum matching number and its nullity vertices. While literature <xref ref-type="bibr" rid="scirp.144910-6">
      [6]
     </xref> <xref ref-type="bibr" rid="scirp.144910-7">
      [7]
     </xref> provides an algorithm for calculating the maximum matching number in bipartite graphs with time complexity 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         O 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <mi>
           m 
         </mi> 
         <mi>
           n 
         </mi> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math>, where m represents the number of edges and n denotes the vertex count, the implementation of this algorithm proves challenging. In contrast, literature <xref ref-type="bibr" rid="scirp.144910-8">
      [8]
     </xref> presents a nullity algorithm for trees that achieves a time complexity of 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         O 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <mrow> 
          <mrow> 
           <msup> 
            <mi>
              n 
            </mi> 
            <mn>
              2 
            </mn> 
           </msup> 
          </mrow> 
          <mo>
            / 
          </mo> 
          <mn>
            2 
          </mn> 
         </mrow> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> when determining maximum matching.</p>
   </sec>
  </sec><sec id="s3">
   <title>3. Case Analysis</title>
   <p>
    <xref ref-type="fig" rid="fig1">
     Figure 1
    </xref> is a tree with 11 vertices and 4 layers.</p>
   <fig id="fig1" position="float">
    <label>Figure 1</label>
    <caption>
     <title>Figure 1. A tree with 11 vertices and 4 layers.</title>
    </caption>
    <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2313303-rId108.jpeg?20250819041306" />
   </fig>
   <p>According to the above algorithm:</p>
   <p>Input: Represent the tree T in the form of a generalized list</p>
   <p>"A(B(D(,E(H,F)),C(G(I(,J(,K))))))"</p>
   <p>Output: Storage structure of tree T, <xref ref-type="fig" rid="fig2">
     Figure 2
    </xref> is the storage structure diagram of tree T with 5 fields.</p>
   <fig id="fig2" position="float">
    <label>Figure 2</label>
    <caption>
     <title>Figure 2. Storage structure of tree T.</title>
    </caption>
    <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2313303-rId109.jpeg?20250819041306" />
   </fig>
   <p>
    <xref ref-type="fig" rid="fig3">
     Figure 3
    </xref> is matching results:</p>
   <fig id="fig3" position="float">
    <label>Figure 3</label>
    <caption>
     <title>Figure 3. Storage structure diagram of tree T after matching is completed.</title>
    </caption>
    <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2313303-rId110.jpeg?20250819041306" />
   </fig>
   <p>Matching edge set: GK, EH, BF, AC, the maximum number of matches is 4, and its nullity is 11 − 2*4 = 3.</p>
  </sec><sec id="s4">
   <title>4. Conclusion</title>
   <p>To facilitate the calculation of the zero degree of a tree, this paper completes the input of the tree in the form of a generalized list, adopts a 5-field node storage method to store the tree, and then applies the relationship between the maximum matching number and the zero degree of the tree to calculate the maximum matching number and zero degree of any tree. The nullity algorithm of trees can be applied to the fields of network stability analysis and signal processing. By analyzing the nullity of a graph (i.e., the number of zero eigenvalues of the matrix), the stability or anti-interference capability of a system can be evaluated. For example, in communication network design, the nullity algorithm can be used to assess the network’s resistance to noise or signal interference; in circuit design, it can be used to predict the system’s resonance characteristics at specific frequencies. The nullity of trees has a good application background, and there are many problems related to the nullity that need to be solved. For example, the implementation of better hierarchical sorting for large vertex trees, the construction of more concise input representation forms for trees; the general nullity algorithm for graphs and its implementation have not been given yet.</p>
  </sec>
 </body><back>
  <ref-list>
   <title>References</title>
   <ref id="scirp.144910-ref1">
    <label>1</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Von Collatz, L. and Sinogowitz, U. (1957) Spektren endlicher grafen. Abhandlungen aus dem Mathematischen Seminar der Universität Hamburg, 21, 63-77. &gt;https://doi.org/10.1007/bf02941924
    </mixed-citation>
   </ref>
   <ref id="scirp.144910-ref2">
    <label>2</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Longuet-Higgins, H.C. (1950) Some Studies in Molecular Orbital Theory I. Resonance Structures and Molecular Orbitals in Unsaturated Hydrocarbons. The Journal of Chemical Physics, 18, 265-274. &gt;https://doi.org/10.1063/1.1747618
    </mixed-citation>
   </ref>
   <ref id="scirp.144910-ref3">
    <label>3</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Cvetkovic, D.M., Doob, M. and Sachs, H. (1985) Spectra of Graphs. Johann Barth Verlag.
    </mixed-citation>
   </ref>
   <ref id="scirp.144910-ref4">
    <label>4</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Cvetkovic, D.M., Gutman, I. and Trinajstic, N. (1972) Graph Theory and Molecular Orbitals, II. Croatica Chemica Acta, 44, 365-374.
    </mixed-citation>
   </ref>
   <ref id="scirp.144910-ref5">
    <label>5</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Cvetkovic, D.M. and Gutman, I. (1972) The Algebraic Multiplicity of the Number Zero in the Spectrum of a Bipartite Graph. Matematički Vesnik, 9, 141-150.
    </mixed-citation>
   </ref>
   <ref id="scirp.144910-ref6">
    <label>6</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Schwenk, A.J. (1973) Almost All Trees Are Cospectral. In: Harary, F., Ed., New Directions in the Theory of Graphs, Academic Press, 275-307.
    </mixed-citation>
   </ref>
   <ref id="scirp.144910-ref7">
    <label>7</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Tan, X.Z. and Liu, B.L. (2005) On the Nullity of Unicyclic Graphs. Linear Algebra and its Applications, 408, 212-220. &gt;https://doi.org/10.1016/j.laa.2005.06.012
    </mixed-citation>
   </ref>
   <ref id="scirp.144910-ref8">
    <label>8</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Wu, T.Z. and Hu, S.B. (2010) Zeroth Degree of Graphs T with Radius Less than or Equal to Half the Spectrum. Journal of Southwest Normal University (Natural Science Edition), No. 4, 95-99.
    </mixed-citation>
   </ref>
  </ref-list>
 </back>
</article>