Next in BST

A Binary Search Tree is a structure in the form of a binary tree,
satisfying that for every node, the values of all the nodes in its left
subtree are smaller than its value, and the values of all the nodes in
its right subtree are greater (we are assuming the tree has no repeated
nodes).

Consider the following implementation of a node of a BST:

        struct bst_node
        {
            int m_value;
            bst_node* m_parent = nullptr;
            bst_node* m_left = nullptr;
            bst_node* m_right = nullptr;
        };

Implement the function

        bst_node* next(bst_node* node);

that returns the node with the smallest value that is greater than the
value of the current node, or nullptr if the current node has the
greatest value.

Observation

You only need to submit the required classes; your main program will be
ignored.

Strictly obey the type definitions of the statement.

Problem information

Author: Xanadu Trading

Generation: 2026-01-25T21:53:47.431Z

© Jutge.org, 2006–2026.
https://jutge.org
