From the course: Python Data Structures: Trees

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: Adding a balance indicator to the printed tree

Challenge: Adding a balance indicator to the printed tree - Python Tutorial

From the course: Python Data Structures: Trees

Start my 1-month free trial

Challenge: Adding a balance indicator to the printed tree

(upbeat music) - [Instructor] In the last section, we looked at determining the balance of the tree at any given node. And this is going to be a really important thing to track throughout the next chapter. So for this reason, it'd be really nice if we could see the balance of our tree in our print function. Remember the function from the challenge in the last chapter. So for this challenge, I want you to modify the tree printing code from chapter one to indicate whether or not a tree is balanced. You might write in the height differences at each node or at each point, an indicator on the exact node, maybe get really crazy and look into libraries that print text in different colors. Whatever you want to do, up to you. Have fun with it. And I'll see you in the next video.

Contents