azzy3897 azzy3897
  • 22-08-2019
  • Computers and Technology
contestada

Help to how to write pseudo code to insert a new node to Binary Search Tree. Using C++.

Respuesta :

ExieFansler ExieFansler
  • 28-08-2019

Answer:

Let the function be Node* ins(Node *root,int k)

if root node is NULL then return new node with data equal to k.

If the k <root->data

root->left=ins(root->left,k);

else if k >root->data

root->right =ins(root->right,k);

At last return root.

Explanation:

Node is always inserted at the at the leaf node.We will search k in the tree if we hit a the leaf node the new node is inserted as the child of the leaf node.

Answer Link

Otras preguntas

An allergic reaction may increase the number of what?
use the order of operations to evaluate each expression. 4x4+3
Ken spends 1/5 of his money on a dictionary. He gives $21 to his brother and has1/2 of his money left. How much money does Ken have left?
What is the largest part of the earth: the core,the mantle, or the crust
An allergic reaction may increase the number of what?
The radius of a circle is 4. The diameter is 8. The radius of a triangle is 8. The diameter is 16. Which shape has the least amount of square feet?
why are humans more like animals than plants
allen runs 8 miles in 3 hours at a steady pace.  how long does it take him to run 3 miles
Good thesis statement on how Androids better than iPhones?
the perimeter of a square is 1 meter. how many centimeters long is each side?