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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:10:48+00:00 2026-06-05T14:10:48+00:00

i need some help with this problem. I have a binary tree stucture which

  • 0

i need some help with this problem.

I have a binary tree stucture which shows all paths between 2 nodes “1” and “10” as shown in the diagram. and the interconnections between the node(i.e. edges) have certain weights.

Now can anybody sugest me an algorithm or a flow as to how to calculate the following.

now let us take paths from “1” to “10”
“a) 1 to 2 to 3 to 10”
“b) 1 to 2 to 4 to 8 to 10”
“c)1 to 2 to 4 to 7 to 10 etc”

now the way the calculation is done is liek a series/parallel circuit.

wherevr the node branches into 2 I need to calculate the series resistance values

for example if i just consider two paths” a) 1 to 2 to 3 to 10 and 1 to 2 to 4 to 8 to 10″

we can see that there is a branch at 2 .. so i add all edge values from” 2 to 3 to 10″ and “2 to 4 to 8 to 10 “and then multiply these two sums and then add value from “1 to 2” to get the overall value.

this has to be done over the entire tree.. any ideas as to how to go about implimenting this in C ??

Image can be found here : https://i.stack.imgur.com/PlXiT.png

  • 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-05T14:10:49+00:00Added an answer on June 5, 2026 at 2:10 pm

    I take it that you want to calculate some esoteric value for a tree, which is defined on each node by some calculation based on the subtrees’ values. That’s not that hard, using a recursive function:

    struct node {
      struct node* left, *right;
      int left_weight, right_weight; /* or something*/
    };
    
    int calculate_it(struct node* root)
    {
      /* do the calculation */
      if(root->left && root->right) {
        int l = calculate_it(root->left) + root->left_weight;
        int r = calculate_it(root->right) + root->right_weight;
        return l*r;
      } else if(root->left || root->right) {
         return root->left ? calculate_it(root->left)+root->left_weight :
           calculate_it(root->right)+root->right_weight;
      }
      return 0;
    }
    

    I’m not sure that I understand your problem, but that should give you the idea.

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

Sidebar

Related Questions

I need some help in solving this problem. We have a large amount of
ASP.NET 4.0 Need some help with this vexing HTTP POST problem - I have
I need some help on this problem. It is about ASP.NET MVC3. I have
I need some help formulating this query. I have two (relevant) tables, which I
I need some help in this problem I have this matrix in MATLAB: A
I need some help! I have no doubt this is a dumb problem that
Need some help with this problem in implementing with XSLT, I had already implemented
Well i need some help here i don't know how to solve this problem.
I really need some help with this as I have been trying to fix
We Really need some help on this one: We've Struggled with all the Apple

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.