Question: Question 25 Recall how we defined a recursive size(u) method in class, that returned the number of nodes in the tree rooted at node u

 Question 25 Recall how we defined a recursive size(u) method in

class, that returned the number of nodes in the tree rooted at

Question 25 Recall how we defined a recursive size(u) method in class, that returned the number of nodes in the tree rooted at node u Not yet answered Consider removing the recursion, using our trusty "traverse20" method: Marked out of 1.00 0 Flag question 1 2 3 4 5 6 void traverse2() { Node u = r, prev = nil, next; while (u != nil) { if (prev == u.parent) { // from parent, go I if can if (u.left != nil) next = u.left; else if (u.right != nil) next = u.right; else next = u.parent; } else if (prev == u.left) { // from L, go Rif can if (u.right != nil) next = u.right; else next = u.parent; } else { // from R, go back to parent next = u.parent; } 7 8 9 10 11 12 13 prev = u; 14 u = next; 15 } 16 ) We're going to add a variable "n" to this method whose purpose is to compute the number of nodes in the tree rooted at r, i.e. the tree's size. Change 1: Add the line "int n = 0;" between lines 1 and 2. Change 2: We need to increment n in the appropriate place(s). Select the best option from the choices given. Select one: O a. add "n++;" between lines 10 and 11 O b. add "n++;" between lines 3 and 4 O c. add "n++;" between lines 7 and 8 O d. add "n++;" into the else statements at lines 6 and 9. O e. add "n++;" into the if statement at line 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!