Tags: avl-tree misc
Rating:
# CSAW CTF 2018: bin_t





## 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.
## Summary
Create a Python script that inserts all values given by server into an AVL tree and that traverse it in preorder
## Flag
```
flag{HOW_WAS_IT_NAVIGATING_THAT_FOREST?}
```
## Detailed solution
We find a [gist](https://gist.github.com/girish3/a8e3931154af4da89995) with an implementation of *AVL trees* in *Python*. Over this code, we construct our preorder traverse function, `preorder_traverse()`.
In the main script, we get the values(that must be entered in the tree) with **pwntools**. After that, these values are introduced into a new `AVLTree` object and we call `preorder_traverse()` function whose result is sent to the server. Then, we receive the flag.