Known in-order traversal and post-order traversal, the establishment of binary tree non-recursive algorithm design

Known in-order traversal and post-order traversal, the establishment of binary tree non-recursive algorithm design

topic

Known in-order traversal and post-order traversal, the establishment of binary tree non-recursive algorithm design

analysis

  • Point-by-point insertion method, insert the post sequence into the middle sequence.
    Assume post sequence POSOD[0…n-1], middle sequence is INOD[0…n-1]

  • When inserting, traverse each element of POSOD in reverse order

  • When inserting, it is actually to find the position of each element in the subsequent sequence in the middle-order data.

Code

Here is a screenshot of the code, if you want to see the source code, go here.
The specific path is this file in "pager/pager_1998.c" . When looking at the screenshot, pay attention to the number of lines of code.
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/honeylife/article/details/100932984