Delete node from bst problem doubt


there are lot of errors so please help me regarding the code.

@Aryanomar00

  1. Put a semicolon after class declaration in Line No. 14
  2. Declare the data elements in the class as public , since it is considered private otherwise if not specified.

i think i am printing wrong pre order please help output.

@Aryanomar00

  1. Add the return root; statement at the end of InsertInBST function
  2. Remove the = condition in deleteInBST function from left and right part check i.e.
    change else if(data<=root->data) to else if(data< root->data) or otherwise if the data is equal , the last else if condition will never be hit. Change the same for right part check as well.
  3. In this problem , in the particular case when the node to be deleted has two children , you are picking the inorder successor ( min value from right subtree ) as its replacement. However the online judge in this problem expects you to choose inorder predecessor ( max value from left subtree ) as its replacement. While both are suitable candidates for being the replacements , it depends from problem to problem which they ask. Make the according changes and let me know if you need any help with it.