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

Factorisationremove the bracket from the following -9(-2k -3r)​
2. What is the total voltage drop across the first and second resistor? 8v 10v 0 12v
45,000 mL= I really need this answer just one more Time lol
How do trigonometric identities and equations help you solve problems involving real or complex numbers?
Can someone do this?
Bonita Industries uses the periodic inventory system. For the current month, the beginning inventory consisted of 481 units that cost $60 each. During the month
1. What territory did the United States gain as a result of the Mexican Cession? Notebook
Help please........jasjjskzkxkx
A fierce debate exists between policymakers as to whether or not they should use monetary and fiscal policies to stabilize small fluctuations in the economy. Pl
Help me solve this spanish questions.