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 6564613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:59:22+00:00 2026-05-25T13:59:22+00:00

I am in the process of converting recursive function for a BST to non

  • 0

I am in the process of converting recursive function for a BST to non recursive to help prepare for an interview. So far I figured out preorder, inorder, postorder, search, delete, insert, and converting the BST to a circular linked list. I am having trouble figuring out how to use stack or queues to get the height and to find if it is a BST. Any tips would be greatly appreciated. I am not looking for code but the logic behind the code.

  • 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-25T13:59:23+00:00Added an answer on May 25, 2026 at 1:59 pm

    For starters, great job preparing for interviews like this! I hope that you’re having fun playing around with these algorithms.

    Let’s begin with the task of trying to determine if the binary tree is a BST. One way of doing this is to do an inorder walk of the tree and check if the elements are in sorted order. This will be true if and only if the tree is a BST. Since you already have code to do an inorder walk of the elements of the tree, you should be able to easily adapt your code to check if the elements that come out of the inorder walk are sorted by keeping track of the last element you saw in the inorder walk, then comparing each element generated to the previous element. If the two are out of order, the tree is not a BST.

    To determine the height of the tree, one option would be to take any of the searches that you’ve come up with so far (preorder, postorder, inorder) and keep track of the height of the stack at each point. The idea here is that since your stack will always keep track of the path back from any node up to the root, you can simply walk the tree and record the deepest that you ever saw the stack become. This maximum depth is then the height of the tree.

    Hope this helps! And best of luck with interviews!

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

Sidebar

Related Questions

I'm in the process of converting my non secure socket to ssl, using boost::asio::ssl
What is the process of converting win32 application (a small popup window actually) to
I'm in the process of converting a varchar(8000) field to an xml field in
I was in the process of converting a VS2003 project (.NET 1.1) to VS2008
I am in the process of converting a VS 2008 Web Site to a
I'm in the process of converting some LaTeX documentation to restructured text and having
I am in the process of converting an Access database to SQL Server 2005.
I am in the process of converting our logging implementation to use System.Diagnostics.TraceSource. We
Our shop is in the process of converting our internal project management application from
Has anybody gone through the process of converting a real-world business application from ASP.NET

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.