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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:52:16+00:00 2026-05-26T08:52:16+00:00

for a programming assignment, I have to load a tree into an array in

  • 0

for a programming assignment, I have to load a tree into an array in order.

The recursive algorithm itself is no problem for me. The problem I’m having is keeping the subscript/element numbers increased periodically so that the data goes into the right array element, instead of overwriting each other after calls return.

void foo( currentNode, data[], element? )
{
    // base case
    if ( currentNode == NULL )

    foo( currentNode->left, data, element? );
    data[ element++ ] = currentNode->data; // what do I do in between the left and right subtree calls?
    foo( currentNode->right, data, element? );
}

So, how do I increase the element so that it only increases to the next spot of the array for an inorder traversal?

Hints are nice, but I wouldn’t mind solutions.

  • 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-26T08:52:17+00:00Added an answer on May 26, 2026 at 8:52 am

    Make your data parameter a reference to a pointer:

    void foo(Node* currentNode, ContentType*& data) {
      //...
      *data++ = currentNode->data;
      //..
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Tkinter in a programming assignment and have the following problem. I
For a programming assignment, we have the following requirements: It needs to be a
I obviously do not 'grok' C++. On this programming assignment, I have hit a
I have this programming assignment that converts between meters and feet, and between kilograms
Hello I have one c++ Programming assignment question. I tried hard but somehow I
i have a unix c programming assignment in which i do some advanced C
I have an assignment from my programming class, which is very poorly worded... The
I am new to the Go programming language and I have an assignment to
for a programming assignment I have been asked to implement a solution to the
I have an programming assignment in Java. I have implemented it by making an

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.