Page 1 of 1

Given the following struct that represents a binary tree: struct Node ( }; int key; Node *parent; Node *left; Node *righ

Posted: Fri Jul 08, 2022 6:44 am
by answerhappygod
Given The Following Struct That Represents A Binary Tree Struct Node Int Key Node Parent Node Left Node Righ 1
Given The Following Struct That Represents A Binary Tree Struct Node Int Key Node Parent Node Left Node Righ 1 (39.17 KiB) Viewed 42 times
Given the following struct that represents a binary tree: struct Node ( }; int key; Node *parent; Node *left; Node *right; Node (int k) key (k), parent (nullptr), left (nullptr), right (nullptr) {}; Write a recursive function that inserts a node in a binary search tree stored using the above structure. If the node passed in is a null pointer, then create the root node. Otherwise, add the node to the binary search tree. You can assume no equal keys will be added to the binary search tree and return the node that was originally passed to the function. 910 TOM MAD Use the below function signature (NOTE: this is not a class method) Node *addToBST (Node *node, int k)