Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6803485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:21:01+00:00 2026-05-26T19:21:01+00:00

I have a binary tree, and pre-order traversal. Here is my tree. 15 /

  • 0

I have a binary tree, and pre-order traversal.
Here is my tree.

      15
     / \
   10   23
   /\   /\
  5 12 20 30
    /     /
   11    25
          \
          27  

so result of pre-order : 15 10 5 12 11 23 20 30 25 27. It’s OK

Than I delete 5,12 and 23 elements

Should I get this

          15
         / \
       10   27
        \   /\
        11 20 30
               \
               25

Result:15 10 11 27 20 30 25

or this?

      15
     / \
   10   25
    \   /\
    11 20 30
          /
         27 

Result: 15 10 11 25 20 30 27

P.S I get 2nd case. If it isn’t right, what is wrong with deletion?

UPD: SO the second updated variant is right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:21:02+00:00Added an answer on May 26, 2026 at 7:21 pm

    Your 2nd case is almost right. 27 would be a left node of 30. When deleting a top node of a (sub)tree, you can either replace that node with the right-most node of the left branch or the left-most node of the right branch. In this case, you’ve replaced 30 with the left-most value of the right branch, which is 25. You’d have to perform this recursively as 25 has branches of its own. Once your target node to delete becomes a leaf, delete it.

    First step:

          15
         / \
       10   25
        \   /\
        11 20 30
              /
             23
              \
               27
    

    Second step:

          15
         / \
       10   25
        \   /\
        11 20 30
              /
             27
            / 
           23    
    

    Third (deletion):

          15
         / \
       10   25
        \   /\
        11 20 30
              /
             27
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to perform iterative * pre-order * traversal on a binary tree
I have a binary tree in unordered list that looks like this: <ul> <li>1
i have made an binary tree, and im trying to make an postorder traversal.
please , suppose i have this Binary Tree structure : Type TPMyTree = ^TMyTree;
Okay. I have a binary tree, and this is what I want to do
I have a binary tree where each node can have a value. I want
I have a Binary tree for a mathematical expression(infix), i want to convert directly
I have a binary tree class that is created with a root node and
I have a binary tree of functions and terminal values. I'd like to print
Im having a problem with python.. I have a binary tree node type: class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.