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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:56:41+00:00 2026-06-01T11:56:41+00:00

I have a tree, each node contains an array children nodes (Node *children_nodes), as

  • 0

I have a tree, each node contains an array children nodes (Node *children_nodes), as well as the name (char *node_name) and parent (Node *parent). each of these are dynamic.
I want to delete a child node from the *children_nodes array, freeing the memory allocated to it’s name and children, (let’s pretend we are deleting a child with no children), and move the location of the last child of the list to the location of the one we just deleted. how can I do this without making the last node get changed if I want to use the location it was in.

Example- I have a node with three children, I want to free children_nodes[0]’s allocated memory and put children_nodes[2] in that spot, preferably just making children_nodes[0] point to the node of children_nodes[2] and then making children_nodes[2] point to nothing without messing with the node itself.

  • 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-01T11:56:42+00:00Added an answer on June 1, 2026 at 11:56 am

    It’s difficult to tell for sure without seeing some code, but I believe you want a Node** children_nodes, so you can just do something like this:

    free(children_nodes[0]);
    children_nodes[0] = children_nodes[2];
    children_nodes[2] = 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a binary tree which contains pointers at each node going to
I have a tree structure where each Node has a parent and a Set<Node>
I have a n-ary tree which contains key values (integers) in each node. I
I have a large tree that grows as my algorithm progresses. Each node contains
I have a table that contains my node data in a tree view. Each
Suppose I have a table nodes where I store a tree. Each node has
I have a JSON tree that contains nodes and children - the format is:
I have a binary tree where each node can have a value. I want
I have a N-Ary non sorted in any way tree and each node can
I want to have a tree in memory, where each node can have multiple

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.