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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:56:37+00:00 2026-06-08T05:56:37+00:00

All right, this question requires a bit of reading on your side. I’ll try

  • 0

All right, this question requires a bit of reading on your side. I’ll try to keep this short and simple.

I have a tree (not a binary tree, just a tree) with data associated to each node (binary data, I don’t know what they are AND I don’t know how long they are)

Each node of the tree also has an index which isn’t related to how it appears in the tree, to make it short it could be like that:

enter image description here

The index number represents the order the user WANTS the tree to be navigated and cannot be duplicated.

I need to store this structure in a file on the disk.

My problem is: how to design a flexible disk storing format that can make loading and working on the tree as easy as possible.

In fact the user should be allowed to

  • Create a child block to an element (and this should be easy enough, it’s sufficient to add data to the file paying attention to avoiding duplicated indices)
  • Delete a child (I should prompt the user “do you want to delete all this node’s children as well? or should I add its children to its parent?”). The tricky part about this is that deleting a node could also free up an index, and I can’t let the user use that index again when adding another node (or the order he set could be messed up), I need to update the entire tree!
  • Swap an index with another one

I’m using C++ and Qt and by now I thought of a lot of structures with a lot of fields like this one

struct dataToBeStoredInTheFile
{
    long data_size;
    byte *data; //... the data here

    int index;
    int number_of_children;
    int *children_indices; // ... array of integers
}

this has the advantage to identify each node with its respective index, but it’s highly slow when swapping indices between two nodes or deleting a node and updating each other node’s index because you have to traverse all the nodes and all their “children_indices” arrays.

Would using something like an “hash” to identify each node be more flexible?
Should I use two indices, one for the position in the tree and one for the user’s index? If you have any better idea to store the data, you’re welcome

  • 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-08T05:56:39+00:00Added an answer on June 8, 2026 at 5:56 am

    I would suggest using something like boost.serialization, then you don’t have to worry about the actual format when save on disk, and can concentrate on effective in-memory solution.

    Edit: Re-reading your question I see you are using Qt, in that case it should have it’s own serialization framework that you can use.

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

Sidebar

Related Questions

This may be a bit of an odd question, and what I have in
There's a shortcut to this without having to specify SET all the time right?
I want add my custom sidebar next right column all page. Please check this
First of all I don't know if this is the right approach. I want
Right so, I'm not particularly skilled at this at all, this is in fact
All right, I'll try to explain my problem as clearly as I can. I
All right so I tried using the button set. So fair, I have been
I'm using the OnIdle-event for some simple animations, and it works all right. The
Okay to keep it short: I have some different websites with tables containing information
--EDIT-- I believe this is a valid question that may have multiple answers (as

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.