In-order Traversal
Lesson 8 of 13 in Coddy's Binary Tree - Data Structures Series #3 course.
Challenge
EasyIn-order traversal:
- Traverse the left subtree
- Visit the root
- Traverse the right subtree
Add to BinaryTree the method inOrderPrint that prints the values in-order, each followed by a space.
Try it yourself
#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_inOrderPrint(&bt);
return 0;
}
All lessons in Binary Tree - Data Structures Series #3
2Binary Tree Project
Node ClassNode with Sons