869 views
0 0 votes

A Binary Search Tree is constructed by inserting the following sequence of keys one by one:
$$40,20,10,30,60,50,70$$
Suppose we delete the root node $(40)$ using the Inorder Successor replacement strategy. What will be the new root of the tree, and what will be the total number of leaf nodes in the resulting tree?

  1. New Root$: 50;$ Leaf Nodes$: 3$
     
  2. New Root$: 50;$ Leaf Nodes$: 4$
     
  3. New Root$: 30;$ Leaf Nodes$: 3$
     
  4. New Root$: 60;$ Leaf Nodes$: 3$

1 Answer

0 0 votes


Inorder Successor: The smallest node in the right subtree. The right subtree consists of $\{60,50,70\}$. The smallest value is $50$.

Replacement: Replace the value of the root $(40)$ with the successor $(50).$

Removal: Delete the original successor node $(50)$ from the right subtree.

Answer:
Position:
Show:

Related questions

0 0 votes
1 1 answer
117
117 views
GO Classes asked Feb 10
117 views
Consider the following three functions of $n$ (where $n$ is a large positive integer):$f(n)=n^{\log _2 n}$ $g(n)=2^{\sqrt{n}}$ $h(n)=n!$ Which of the following correctly ...
1 1 vote
1 1 answer
146
146 views
GO Classes asked Feb 10
146 views
Suppose you are given a singly linked list with $n$ nodes and a pointer '$p$' pointing to the $k$-th node $(1<k<n)$. You want to delete the $k$-th node itself, but you ar...
1 1 vote
1 1 answer
130
130 views
GO Classes asked Feb 10
130 views
Consider a Directed Acyclic Graph (DAG) with $V$ vertices and $E$ edges. A 'Source' vertex is defined as a vertex with an in-degree of $0$. If we perform a Topological So...
1 1 vote
1 1 answer
124
124 views
GO Classes asked Feb 10
124 views
Consider the following postfix expression:$$10~~~5~~+~~60~~~6 ~~/~~ *~~ 8~~-$$A single stack is used to evaluate this expression. What is the maximum number of elements p...