[WUSTCTF2020] nivel 4
paso
- elf, intente ejecutar la máquina virtual para ver la situación general,
Typing....Struct.....char....*left....*right............emmmmm...OK!
suponga que hay un árbol binario de acuerdo con los caracteres del indicador.
Puedo ver que las cadenas en type1 y type2 son un poco como banderas, pero el orden está interrumpido - 64 ida Cargando
type1 (byte_601290), un orden transversal del árbol binario: 2f0t02T} {hcsiI_SwA__r7Ee
20f0Th} {2tsIS_icArE e7__w: Type2 (byte_601290), la secuencia transversal del árbol binario
en el árbol binario, introduzca antes, después de comprender los principios del árbol binario. ser determinado Ordenado. Manual al principio, a la mitad de la escritura, encontré demasiado y cambié el guión
Fuente de Python3 exp
: https://blog.csdn.net/weixin_41287060/article/details/99400963
#使用中序后序求前序遍历
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def reConstructBinaryTree(self, post, tin):
if len(post) == 0:
return None
root = TreeNode(post[-1])
TinIndex = tin.index(post[-1])
root.left = self.reConstructBinaryTree(post[0:TinIndex], tin[0:TinIndex])
root.right = self.reConstructBinaryTree(post[TinIndex:len(post) - 1], tin[TinIndex + 1:])
return root
def PreTraversal(self, root):
if root != None:
print(root.val,end="")
self.PreTraversal(root.left)
self.PreTraversal(root.right)
strm="2f0t02T{hcsiI_SwA__r7Ee}"
stre="20f0Th{2tsIS_icArE}e7__w"
post = list(stre)#后序
tin = list(strm)#中序
S = Solution()
root = S.reConstructBinaryTree(post, tin)
S.PreTraversal(root)
marcar {This_IS_A_7reE}