Tags: data-structure avl-tree 

Rating:

**Description**

> Binary trees let you do some interesting things. Can you balance a tree?
>
> `nc misc.chal.csaw.io 9001`
>
> Equal nodes should be inserted to the right of the parent node. You should balance the tree as you add nodes.

**No files provided**

**Solution** (by [PK398](https://github.com/PK398))

The challenge gives you ~100 numbers and tells you to insert the numbers into an AVL Binary Tree and then do a pre-order traversal. The concept of trees should be familiar to programmers and should be able to insert into an AVL tree and be able to do a left and right rotate to balance a tree and if not there are plenty of implementations available online. Once the tree has been constructed, we can traverse it in a pre-order manner (print root, traverse the left subtree and then the right subtree) and print it as a comma-separated list and sending it back to the server gives us the flag.

`flag{HOW_WAS_IT_NAVIGATING_THAT_FOREST?}`

Original writeup (https://github.com/Aurel300/empirectf/blob/master/writeups/2018-09-14-CSAW-CTF-Quals/README.md#50-misc--bin_t).