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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:03:17+00:00 2026-06-11T21:03:17+00:00

I am doing some personal research and came across a need to efficiently modify

  • 0

I am doing some personal research and came across a need to efficiently modify data in a (possibly very large) tree of data. The data consists of simple data, just an integer or possibly a small object. While parsing the tree, I will need to modify all similar objects (but only objects within the subtree). This is a bit confusing to explain, so I have added an image as an example to help.

example

In the above image, letters represent a value for the data (identical letters represent identical data), and the numbers in parenthesis are a unique value so I can refer to them.

So lets say I am parsing the tree and I am currently at node 2. I have determined that I need to modify the value of ‘a’ and change it to ‘g’, but I only want to modify the current node and all children. (so 2 and 9 will change to ‘g’, while 1 and 7 remain ‘a’). I could recursively search all children and change it manually, but the tree may be very large. If I wanted to change ALL of the values of a, I could simply store data as a double pointer, and change the value that the pointer points to. So my question is, is there any known method to modify the data in the way I want, in possibly constant time?

  • 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-06-11T21:03:18+00:00Added an answer on June 11, 2026 at 9:03 pm

    The way I would do it would be on insertion to the tree.

    Make a class for node

    class node
    {
        node* dataParent;
        CustomType* value;
        // put regular tree pointers here
    }
    

    Then when you insert as you traverse, dataParent points to the last parent that had identical data. If there are no parents that are identical it will be null and value will not be null. If it has a parent that is identical, value will be null and something will be in Custom parent. Your retrieval will not be constant time though, you will have to traverse until value is not null.

    This is the best way I can think of. It is at least log n i think. Its been awhile.

    One thing is insertion will be costly.

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

Sidebar

Related Questions

I'm doing some personal research into text analysis, and have come up with close
I need this function for some personal work and although doing this in general
I'm doing some template work on a personal project and I'm trying very hard
While doing some JavaScript performance tests I came up with the following piece of
After doing some research on the subject, I've been experimenting a lot with patterns
I'm doing some research for a project that I might be doing soon, and
I'm doing some web scraping to build up a personal SQL database. As I'm
I'm currently doing some research on OpenGL and Shaders but I can't seem to
I'm doing some research into databases and I'm looking at some limitations of relational
I've been doing some research into taking my programming experience and moving into the

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.