PTA questions
6.1 jmu-ds-binary tree operation set>
Design ideas
The main function CreateBTree (&BT, str), create a new node -> T; create a new queue -> Q, use if to judge whether it is empty, if str is not empty, BT pushes the stack, if str is empty, exit the function, if Q is not Empty, create the first node of the queue, dequeue the first element of the queue if str=# or empty T->left=empty, else create a left node of T, push the left node of T into the stack Q if str=# or empty T-> Right=empty else Create the right node of T, and push the right node of T into the stack Q.
Code display:
6.4 jmu-ds-expression tree
Design ideas:
Build an expression binary tree, define a stack to store numbers used for operations, and define a character stack to store numeric operation symbols.
Code display:
Problem: The understanding of recursion is not thorough enough.
Read the code: https://wenku.baidu.com/view/b96462d34693daef5ef73deb.html