Programming Challenge: Construct and traverse a binary tree.

Emerald_Knight
Tue, 10 Jul 2018 06:17:29 +0000

It's that time of week again! For this week's programming challenge, I thought I would focus on data structures.

Goal: Construct a binary tree data structure. It may handle any data type you choose, but you must handle sorting correctly. You must also provide a print function that prints each value in the tree on a new line, and the values must be printed in strictly increasing order.

If you're unfamiliar with this data structure, it's a structure that starts with a single "root" node, and this root can have a left child, right child, both, or neither. Each of these child nodes is exactly the same as the root node, except the root has no parent. This branching structure is why it's called a tree. Furthermore, left descendants always have values smaller than the parent, and right descendants always have larger values.

Comments URL: https://tildes.net/~comp/387/programming_challenge_construct_and_traverse_a_binary_tree

Votes: 12

Comments: 11