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

Digestion takes place inside _______ containing _______?
Brett and rose's mother donated $7 for every lap they walked in the walk a thon. Brett walked 16laps and Rosa walked 19 laps. write an expression and solve t
123 cm3 = mm ? 3.6 cm2 = dm2 ?
who directed the work of slaves
What is the only hemisphere and watch Antarctica has no land
Poetry is a creative art form, full of beautiful language and unique observations. Poets use metaphors, symbolism, and other types of figurative language to con
Under certain circumstances can the house elect the president?
what is the word when a animal reproduces by itself not sexually
Mealtimes always found my grandmother in the kitchen, laying out the dinnerware for the feast my grandfather was cooking—a freshly caught king salmon, or pork
Which measure is equivalent to 12 yd? a. 4 ft b. 6 ft c. 36 ft d. 144 ft