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

  • SEARCH
  • Home
  • 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 1081349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:09:28+00:00 2026-05-16T22:09:28+00:00

We are given a binary search tree; we need to find out its border.

  • 0

We are given a binary search tree; we need to find out its border.

So, if the binary tree is

           10
       /         \
     50           150
    /  \         /   \
  25    75     200    20
 / \           /      / \
15 35        120    155 250 

It should print out 50 25 15 35 120 155 250 20 150 10.

If the binary tree is

               10
           /         \
         50           150
        /  \         /   
      25    75     200   
     / \   / \    
    15 35 65 30  

It should be like 50 25 15 35 65 30 200 150 10.

How can this be done? Does generalising this for a binary tree make the problem any harder?

Any help through links will also be appreciated.

P.S.: please see that the pattern does not start from root but from the left (in this case). It might also start with right, but it always ends with the root.

  • 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-16T22:09:28+00:00Added an answer on May 16, 2026 at 10:09 pm

    What you are asking for is a modified depth-first traversal where the node’s values are only printed/returned if either 1) the node is a leaf node or 2) the node is along the “outer path” of the tree, where “outer path” is defined as

    A node is a part of the “outer path” if you arrived at the node by following all of the left (or right) paths from the root, or if the node is the right (or left) child of a parent node that was itself a part of the “outer path” but had no left (or right) children.

    If you know how to code DFS, then the modification here could be implemented by checking a few extra conditions during the traversal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a binary search tree (BST). Find the maximum depth of the binary search
For a given binary tree, find the largest subtree which is also binary search
Given a binary search tree and an integer K, i would like to find
Given a binary search tree, i need to convert it into a doubly linked
I saw this problem: Given a binary search tree and a number, find a
Given a binary search tree, in which any two nodes are swapped. So we
I wanted to know if a given binary tree is a binary search tree
I need to generate a series of N random binary variables with a given
Given a simple binary tree, how can we prove that tree is a binary
I'm trying to write binary search tree's content to temporary array in order to

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.