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

what is the similarities between string and spoon ?
Summarize current recommendation for aspirations when administering vaccinations to pediatric patients
what is contour line drawing
What useful information can be found on a capacity plate? A, The Hull Identification Number (serial number) of the vessel B, The safety recommendations for t
can somebody help me?
Can someone help translate this?
If we are given the linear inequality -7x + 8y ≤ 56, then what is the largest value for y on the interval -3 ≤ x ≤ 0?
What is an equation in slope-intercept form of the line that passes through the points (−2, −2) and (1, 7)? a. y = 1/3x - 4/3 b. y = 3x + 4 c. y = 1/3x + 20/3 d
options:A. the damming of the Nile riverB. pollution created by farmersC. the deserts surrounding the nileD. yearly flooding of the nile
find the equivalent expression of 3+2(2p+4t)