domingo, 9 de octubre de 2016

EJERCICIO 5 - SEGUNDO CORTE

5. Para cada uno de los siguientes árboles escriba las respectivas expresiones de los recorridos:
pre_orden, in_orden y post_orden. Implemente un algoritmo para uno de ellos. Represente el árbol de B como una lista doblemente enlazada.



SOLUCION

A)
PRE-ORDEN
(10, 8, 6, 4, 3, 2, 5, 7, 9, 11, 14, 12, 13, 21, 22, 24 )

IN- ORDEN
(2 ,3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 12, 14, 22, 21, 24)

POST- ORDEN
(2, 3, 5, 4, 7, 6, 9, 8, 13, 22, 12, 24, 21, 14, 11, 10)

B)
PRE-ORDEN
(/, ^, *, +, ^,  b, 3, ^, a, 2, ^, a, 1/2 , 2, *, 4, +, *, 3, a, ^, b, /, x,2)
IN- ORDEN
(b, ^, 3, +, a, ^, 2, *, a, ^, 1/2, ^, 2, /, 4, *, 3, *, a, +, b, ^, x, /, 2)
POST- ORDEN
(b, 3, ^, a, 2, +, a, ½ , ^, *, 2, ^, 4, 3, a, *, ^, b, x, 2, /, ^, +, *, /)


No hay comentarios:

Publicar un comentario