tree and binary tree

1. Learning summary

1.1 Tree structure mind map

 

 

1.2 Tree structure learning experience

Data can be sorted, as well as search and classification to increase efficiency.

2.PTA experiment work


2.1 Topic 1: 6-1 jmu-ds-binary tree operation set

CreateBTree(&BT,str)
{ new node->T;
new queue->Q;
i=0;
if str is empty
new node->BT;
BT->data=str[i];
BT->left, right=NULL;
BT push Q
else end; i++;
while Q is not null {

The first element of the team is out;
if str='#' or empty
T-> left = NULL
end if
else {new left node of T;
assignment = str[i];
left node of T -> left, right is empty ;
The left node of T is pushed onto the stack Q;
}
i++;
if str='#' or empty
T-> right =NULL
end if
else {Create the right node of T;
assignment=str[i];
The right node of T Point -> left, right is empty;
the right node of T is pushed into the stack Q;
}i++;
}}PreOrder(BT)
if BT is not empty
if flag is 0, output BT value
end if else
output ' ' and BT value
flag= 1;
PreOrder (BT->left);
PreOrder (BT->right);
end if
}{define static variable flag=0;
if BT is not empty
InOrder (BT->left);
if flag is 0, output BT value
else
output ' ' and BT
flag=1;
InOrder(BT->right);
end if
}PostOrder(BT)
{define static variable flag=0;
if BT is not empty PostOrder(BT->left);
PostOrder(BT->right);
if flag is 0 output BT value
else
output ' ' and bt value
flag=1;
end if }

Topic 2: 6-4 jmu-ds-expression tree

2.2 Design ideas (pseudo code or flowchart)

InitExpTree(&T,str) uses two stacks to build a tree {new stack s; new stack op; '#' push op; while (str is not empty) {if is not a symbol NEW T assignment->str[i++]; T- >left, right=NULL; T pushes the stack s; else{switch judges the priority { case'<'; str[i] pushes the stack; i++;case'=': op pops the top element of the stack; i++;case:' >': new; T assigns op stack top element; T-> right=s stack top element; s stack top element pops; T-> left=s stack top element; s stack top element pops; T pushes s ;op stack top element is popped; while op is not '#' {new T node; T assigns op stack top element; T->right=s stack top element; s pops the stack; if s is not empty T-> left = s stack top element; s pop;

2.3 Code screenshots

 

 

 

 

2.4 PTA Submission List Instructions.

Grammar and misuse of some sentences


Topic 3: 7-7 Moments (25 points)

2.2 Design ideas (pseudo code or flowchart)

 

2.3 Code screenshots

 

 

2.4 PTA Submission List Instructions.

 

 

3. Screenshot of the PTA final ranking of this week's topic set

The total score of this topic set: 285 points
The total number of required questions: 230 points

3.1 Screenshot of PTA ranking

 

 

3.2 My total score:

205

4. Read the code (required)

Must do this time

  • Find 1 piece of code related to tree structure, explain what the function of this code is, and what are the advantages?
  • Give the code-related address.

5. Screenshot of code Git commit record

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325303020&siteId=291194637