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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:43:32+00:00 2026-05-27T11:43:32+00:00

I have an AVL Tree. Each node looks like this: typedef struct { Node

  • 0

I have an AVL Tree. Each node looks like this:

typedef struct {
    Node *parent;  // the parent node
    Node *left;    // the node left of this node
    Node *right;   // the node right of this node
    int height;    // the height of this node
    void *value;   // payload
} Node;

Is it possible to iterate over an AVL tree with these nodes in O(1) space, without recursion, if yes, how?

If not, a solution with sub-O(n) space or iff really necessary O(N) space is appreciated as well.

With iterating over the tree I mean I want to visit each node once, and if possible in order (from the mostleft to the mostright node).

  • 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-27T11:43:32+00:00Added an answer on May 27, 2026 at 11:43 am

    If you store the last node you have visited, you can derive the next node to visit in an iterator.

    • If the last node was your parent, go down the left subtree.
    • If the last node was your left subtree, go down the right subtree.
    • If the last node was your right subtree, go to your parent.

    This algorithm gives you a traversal in O(1) for the tree. You need to flesh it out a little for the leaves and decide what kind of iterator (pre/in/post-order) you want to decide where the iterator should and wait for incrementation.

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

Sidebar

Related Questions

I have an AVL tree while each node consists of: Key Value The AVL
I'm working on an AVL tree assignment and I have a quick question about
I have a large AVL Tree which I build some times during program from
I have the following AVL tree: 10 / \ 5 12 / \ /
Assume that I have two AVL trees and that each element from the first
Have a look at this code: #include <iostream> using namespace std; int main() {
We have a database called AVL in SQL Server 2008 R2 SE. This database
I have created an AVL tree implementation, but as an AVL tree is quite
Have you managed to get Aptana Studio debugging to work? I tried following this,
I am trying to implement an AVL tree and not sure about the best

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.