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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:56:09+00:00 2026-05-27T22:56:09+00:00

I am looking at alternatives to a deep search algorithm that I’ve been working

  • 0

I am looking at alternatives to a deep search algorithm that I’ve been working on. My code is a bit too long to post here, but I’ve written a simplified version that captures the important aspects. First, I’ve created an object that I’ll call ‘BranchNode’ that holds a few values as well as an array of other ‘BranchNode’ objects.

class BranchNode : IComparable<BranchNode>
{
    public BranchNode(int depth, int parentValue, Random rnd)
    {
        _nodeDelta = rnd.Next(-100, 100);
        _depth = depth + 1;
        leafValue = parentValue + _nodeDelta;

        if (depth < 10)
        {
            int children = rnd.Next(1, 10);
            branchNodes = new BranchNode[children];
            for (int i = 0; i < children; i++)
            {
                branchNodes[i] = new BranchNode(_depth, leafValue, rnd);
            }
        }
    }

    public int CompareTo(BranchNode other)
    {
        return other.leafValue.CompareTo(this.leafValue);
    }


    private int _nodeDelta;
    public BranchNode[] branchNodes;
    private int _depth;
    public int leafValue;


}

In my actual program, I’m getting my data from elsewhere… but for this example, I’m just passing an instance of a Random object down the line that I’m using to generate values for each BranchNode… I’m also manually creating a depth of 10, whereas my actual data will have any number of generations.

As a quick explanation of my goals, _nodeDelta contains a value that is assigned to each BranchNode. Each instance also maintains a leafValue that is equal to current BranchNode’s _nodeDelta summed with the _nodeDeltas of all of it’s ancestors. I am trying to find the largest leafValue of a BranchNode with no children.

Currently, I am recursively transversing the heirarchy searching for BranchNodes whose child BranchNodes array is null (a.k.a: a ‘childless’ BranchNode), then comparing it’s leafValue to that of the current highest leafValue. If it’s larger, it becomes the benchmark and the search continues until it’s looked at all BranchNodes.

I can post my recursive search algorithm if it’d help, but it’s pretty standard, and is working fine. My issue is, as expected, that for larger heirarchies, my algorithm takes a long while to transverse the entier structure.

I was wondering if I had any other options that I could look into that may yield faster results… specificaly, I’ve been trying to wrap my head around linq, but I’m not even sure that it is built to do what I’m looking for, or if it’d be any faster. Are there other things that I should be looking into as well?

  • 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-27T22:56:10+00:00Added an answer on May 27, 2026 at 10:56 pm

    Maybe you want to look into an alternative data index structure: Here

    It always depends on the work you are doing with the data, but if you assign a unique ID on each element that stores the hierarchical form, and creating an index of what you store, your optimization will make much more sense than micro-optimizing parts of what you do.

    Also, this also lends itself a very different paradigm in search algorithms, that uses no recursion, but in the cost of additional memory for the IDs and possibly the index.

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

Sidebar

Related Questions

I'm looking for alternatives to Chargify for a billing system that can be integrated
I'm looking for alternatives to GraphViz. I've been using GraphViz for more than a
I'm looking for alternatives to Google Book Search API. Ideally, something with more detailed
I am looking for alternatives to the Eclipse built-in Java code formatter. Not stand-alone,
I'm looking at porting some code that uses java.util.concurrent.ConcurrentSkipListSet to an environment where this
I'm looking to find alternatives to Solr from the Apache Software Foundation. For those
I am looking for more advanced alternatives to xsd.exe . I am just about
I'm looking for a tool like Atlassian's FishEye . The alternatives I've found so
Are there any alternatives to the Open Source Job Scheduler ? I'm looking for
We're looking to replace DataGridView in our Winforms app. What are the alternatives -

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.