Python Forum
Print Binary Tree - Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print Binary Tree - Python
#1
def show_2d(self):
    '''
    Show a pretty 2D tree based on the output of bfs_order_star(). None
    values are are replaced by stars ('*').

    For example, consider the following tree `t`:
                10
          5           15
       *     *     *     20

    The output of t.bfs_order_star() should be:
    [ 10, 5, 15, '*', '*','*', 20 ]
    '''
I already got the function bfs_order_star() working like it should. That is a function that returns an array with all of the nodes from a tree in breadth-first traversal, where the empty nodes are declared as '*'.

Any ides how I can write a function that prints a 2D tree based on the data from that array?
Reply


Messages In This Thread
Print Binary Tree - Python - by Daniel94 - Jan-08-2020, 09:41 PM
RE: Print Binary Tree - Python - by ichabod801 - Jan-08-2020, 09:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to print out the children index of the search tree? longmen 7 2,250 Apr-02-2022, 06:58 AM
Last Post: Yoriz
  Binary to decimal, print the decimal rs74 3 2,126 Jul-12-2020, 05:25 PM
Last Post: DPaul
  Return size of binary tree Daniel94 1 2,009 Jan-05-2020, 04:09 PM
Last Post: ichabod801
  Self Paced Web course - split ip and print each piece in binary and hex sumncguy 2 2,397 Dec-04-2019, 06:03 PM
Last Post: jefsummers
  Binary tree for words and simbols OlegBrony 4 5,048 Mar-14-2018, 09:40 AM
Last Post: OlegBrony

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020