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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:21:42+00:00 2026-06-12T22:21:42+00:00

I am implementing a tree Data structure in c# based (largely on Dan Vanderboom’s

  • 0

I am implementing a tree Data structure in c# based (largely on Dan Vanderboom’s Generic implementation). I am now considering approach on handling a Count property which Dan does not implement.

The obvious and easy way would be to use a recursive call which Traverses the tree happily adding up nodes (or iteratively traversing the tree with a Queue and counting nodes if you prefer). It just seems expensive. (I also may want to lazy load some of my nodes down the road).

I could maintain a count at the root node. All children would traverse up to and/or hold a reference to the root, and update a internally settable count property on changes. This would push the iteration problem to when ever I want to break off a branch or clear all children below a given node. Generally less expensive, and puts the heavy lifting what I think will be less frequently called functions.

Seems a little brute force, and that usually means exception cases I haven’t thought of yet, or bugs if you prefer.

Does anyone have an example of an implementation which keeps a count for an Unbalanced and/or non-binary tree structure rather than counting on the fly? Don’t worry about the lazy load, I am sure I can adjust the example to fit my specific needs.

  • 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-12T22:21:44+00:00Added an answer on June 12, 2026 at 10:21 pm

    Thanks everyone for your comments. I didn’t really want to invite debate, just wanted to see if anyone had a sample, which seems not to be the case.

    I think the answer is there isn’t a good sample available and I will need to do the work myself.

    I’ve given each of you a +1 as you have all contributed to my conclusion.

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

Sidebar

Related Questions

I'm currently implementing a very complex tree structure to allow for near-instant data access,
I'm implementing an AVL binary tree data structure in C# .NET 2.0 (possibly moving
I´m having some trouble implementing a dynamic tree structure using the primefaces tree implementation.
suppose i'm implementing a polymorphic tree data structure that can take on data of
I'm currently implementing a red-black tree data structure to perform some optimizations for an
(Using Java) I am implementing a generic class which is a B-Tree. When the
How would one test whether data structure built properly? I'm implementing kind of modified
My data structures class is working with trees. We are implementing a 3-ary tree,
I'm implementing some classes to handle the common data structures (Tree, BinaryTree, Search Binary
I'm trying to teach myself about data structures, and I'm implementing a k-d tree

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.