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

Assertion (A): Secondary active transport does not involve the direct usage of ATP. Reasoning (R): There is no direct involvement of an ATPase to hydrolyze ATP.
Which graph represents exponential decay? 80 형 40 20 - O 2 x 80 60 LI 1401 20 1 2 3 2 3 80 60 40 20 x 80 60 40 20 2 3
what is the gradient if y=-x+3​
Question 19 of 25 Which of the following is most likely the next step in the series? D O A. B. O D. SUBMIT
8/33-5/22 find the difference
Why are open lines of communication important to an effective compliance program?
Visios de lenguaje, me gustan esos antiojos cual Visio de lenguaje sería
Use a calculator to express the first quantity as a percentage of the second, giving your answer correct to two decimal places. (a) 232, 450 (b) 35, 122
how to write ellens eyes are red and itchy from allergies
a team of scientists has consistently gotten the same unexpected results from a set of experiments.Which of the following helps the scientist ensure the reliabi