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

Condense each expression. 5 log5 x - 1/4 log5 (8 -x)
The diagonals of a rhombus are 12cm and 16cm.Find the length of each side.​
what is the value of x? 3 ,4,6,8
a figures skater rotating at 5 rads with arms extended has a moment of inertia of 2.25 kg. if the arms are pulled in so the moment of inertia decrease to 1.8 wh
Please answer it now in two minutes
Select the equation that could represent the relationship between f(x) and g(x).
Which type of mutation occurs only in reproductive cells
Find the exact value of each expression, if it defined. ( if answer is undefined, enter undefined) tan (-1)
Which of the following statements would be represented with P → Q? Question 14 options: A) x = 5 if and only if y = 9. B) x = 5, and 2x ≠ 8. C) x = 5, but y = 9
What is the meaning of the figurative language used in this excerpt? Mark Antony is sweet and kind with his words. Mark Antony steals honey and gives it back to