The level of a node in the tree is the number of nodes in the path from the root to the node (including itself). For example, the node 15 in the example tree above has a level of 2. Write a function prune-tree that will take a tree representation as well as an integer level. It will return a new tree containing only nodes that have level not exceeding level. The order of the nodes in the result list should be the same as the original order in the tree. You may assume that level is a non-negative integer. write the program in racket

icon
Related questions
Question

The level of a node in the tree is the number of nodes in the path from the root to the node (including itself). For example, the node 15 in the example tree above has a level of 2. Write a function prune-tree that will take a tree representation as well as an integer level. It will return a new tree containing only nodes that have level not exceeding level. The order of the nodes in the result list should be the same as the original order in the tree. You may assume that level is a non-negative integer. write the program in racket

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Types of trees
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, data-structures-and-algorithms and related others by exploring similar questions and additional content below.