Pre-order Traversal
Lección 7 de 13 del curso Árbol Binario - Serie de Estructuras de Datos #3 de Coddy.
Desafío
FácilRecorrido en pre-orden:
- Visitar la raíz
- Recorrer el subárbol izquierdo
- Recorrer el subárbol derecho
Añade a BinaryTree el método preOrderPrint que imprima los valores en pre-orden, cada uno seguido de un espacio.
Pruébalo tú mismo
#include <stdio.h>
#include <string.h>
#include "binarytree.h"
int main() {
char buf[4096];
if (!fgets(buf, sizeof(buf), stdin)) buf[0] = '\0';
buf[strcspn(buf, "\r\n")] = '\0';
BinaryTree bt;
BinaryTree_init(&bt);
BinaryTree_buildTree(&bt, buf);
BinaryTree_preOrderPrint(&bt);
return 0;
}
Todas las lecciones de Árbol Binario - Serie de Estructuras de Datos #3
2Binary Tree Project
Node ClassNode with Sons