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

(Very easy) Find the volume. Round to the nearest tenth if necessary.
If BP PC, what is m BC? 60 90 180
A piece rate worker is paid. O A. a fixed rate for each item produced or action performed O B. a fixed rate per year c. a fixed rate per hour worked O D. a fixe
How do you simplify the expression “3x (2/x + 5) +4”?
How does social media influence self image?​
3. Carbon dioxide from cells is delivered from the circulatory system back tothe ________ system so it can exit the body.​
form of Christianity based on Greek heritage practiced in the Byzantine Empire
sec x(sec x + tan x) dx =​
What are the assumptions for the Hardy-Weinberg equation? What does it mean when a population is in Hardy-Weinberg equilibrium?
find the sum of the following without actually adding: 1+3+5+7+9+11+13+15