10 points Question 3 : Trees .. You are asked to implement the following recursive function: TNode. addLayer( TNode root, int val ) Here's the definition of T Node struct: //Put val in here for your new TNodes typedef struct TNode { int key: struct TNode •left, right; TNode: This function replaces the NULLA at the bottom of the tree with new tNodes that contain the specified val as their key. Here's an example of what it would do to a given tree: 30 50 70 NULL NULL NULL 60 SULL NUEL NELL 12 NULL NULL before adaLayer root, 42 ) NULL SELENULI. NULL after addLayer root. 42 ) Remember to mora the testade at the bottom of the tree. If your malloc failur function should cafer Ile with institut Bin Sardele BST this function abond return the Nathat the path tolle point to To here the of this cunables the neth EL. ALI SULE SELL Laft Hallas Tab 137 Before advertent. 13372
The only functions you should call are malloc, sizeof, erit, and addLayer. TNode. addLayer( TNode root, int val ) //Declare any local variables you need //Base case: Recursive case be sure to use the return value from the recall
10 points Question 3 : Trees .. You are asked to implement the following recursive function: TNode. addLayer( TNode root
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
10 points Question 3 : Trees .. You are asked to implement the following recursive function: TNode. addLayer( TNode root
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!