Embed presentation
Download to read offline
![3. [10 points] Given a binary search tree T with a root node r, please write a recursive method N2C
(r) that returns the number of internal nodes with two children in the tree. N2C(r)(r)//r is the root 1 if
r==NIL 2. return 2. if r.left != NIL and r.right != NIL 3. return 4. else 5. return](https://image.slidesharecdn.com/310pointsgivenabinarysearchtreetwitharootnode-230318104550-c68c8ab9/75/3-10-points-Given-a-binary-search-tree-T-with-a-root-node-pdf-1-2048.jpg)
The document outlines a task to create a recursive method named n2c that counts internal nodes with two children in a binary search tree. The method checks the root node and returns specific values based on the presence of child nodes. It includes a logic structure that handles different cases of node presence.
![3. [10 points] Given a binary search tree T with a root node r, please write a recursive method N2C
(r) that returns the number of internal nodes with two children in the tree. N2C(r)(r)//r is the root 1 if
r==NIL 2. return 2. if r.left != NIL and r.right != NIL 3. return 4. else 5. return](https://image.slidesharecdn.com/310pointsgivenabinarysearchtreetwitharootnode-230318104550-c68c8ab9/75/3-10-points-Given-a-binary-search-tree-T-with-a-root-node-pdf-1-2048.jpg)