-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
ExerciseThe exercises that are introduced in the lectures.The exercises that are introduced in the lectures.
Description
Write in Python a recursive function def breadth_first_visit(root_node)
that takes the root node of a tree and returns a list containing all the nodes of the tree according to a breadth first order, which first consider all the nodes of the first level, then those ones of the second level, and so forth. For instance, considering the nodes created in Listing 2, the function called on the node book
should return the following list: [book, chapter_1, chapter_2, text_8, paragraph_1, paragraph_2, paragraph_3, text_7, text_1, quotation_1, text_3, quotation_2, text_5, text_6, text_2, text_4]
. Accompany the implementation of the function with the appropriate test cases.
Metadata
Metadata
Assignees
Labels
ExerciseThe exercises that are introduced in the lectures.The exercises that are introduced in the lectures.