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

To mitigate risks and collect user feedback, development and delivery efforts have been divided into
A 3kw kettle boils water in 4 minutes.does this use more electrical energy than a 150w fridge left on for 1 hour?
Which of the following represents the chemical reaction of boron trichloride and water to produce boric acid and hydrochloric acid?
Which best describes swift’s purpose for writing a modest proposal?
please help with mathshow your work
what were booker t washingtons views imperialism
I doubt someone can do this, but may you fill in the blanks? Thank you so much if you do!
The Bible attempts to prove God's existence. True False
perimeter of square garden with length of 9 feet
what is the answer to 10-A=3