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: Printing a tree

Challenge: Printing a tree - Python Tutorial

From the course: Python Data Structures: Trees

Start my 1-month free trial

Challenge: Printing a tree

(upbeat music) - [Instructor] All right in the previous section, we printed out all the nodes at a specific depth of the tree essentially printing out one row of the tree at a time and you might be thinking to yourself, Hmm if I did this to all of the rows of the tree in order, could I actually see the tree? And the answer is yes. So let's print out trees charter terminal so we can examine them more visually but print functions like this are also a matter of personal taste and style. So how do you draw connections between the nodes? How do you space the nodes? There are a lot of little details and decisions that need to be made. So dust off those old text formatting skills and rise to the challenge. I want you to create a print function for a tree that will display all the nodes of the tree with connections between them in the terminal. Obviously not expecting anything that'll print millions of nodes that…

Contents