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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:21:06+00:00 2026-05-30T13:21:06+00:00

I have generated a minimum spanning tree using Kruskal’s algorithm and I wanted to

  • 0

I have generated a minimum spanning tree using Kruskal’s algorithm and I wanted to know how to store paths

This is my minimum spanning tree

Loc1 |  Loc2 |  Distance
  02 |   10  |    2.00 Km
  05 |   07  |    5.39 Km
  02 |   09  |    5.83 Km
  04 |   05  |    5.83 Km
  06 |   08  |    5.83 Km
  03 |   09  |    7.07 Km
  01 |   04  |    11.18 Km
  07 |   09  |    11.18 Km
  07 |   08  |    15.81 Km
Total Weight = 70.12 Km
----------------------------------------------------
  • 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-30T13:21:08+00:00Added an answer on May 30, 2026 at 1:21 pm

    It depends on how much extra space you have. Assume you need to be space-efficient:

    1. Orient the edges in such a way that the resulting structure has at
      most one parent node for each node. How to do it? Just pick a node and make it the root. It’s children are first level nodes etc
    2. Now store the resulting graph in the format child->parent (In your table you can make Loc1 column child and Loc2 column parent. Index it by child)
    3. For given two nodes, a and y, whose distance needs to be calculated, find their parental sets and see where they intersect. Ex. If parent of x is A, A’s parent is B… the parental path is ABCDLMN (where N is the root). Similarly if the parental root for y is EFLMN. As you can see, the lowest common root for both of them is L. Distance from x->L is 5, y->L is 3, => distance between x and y is 5+3=8.

    Complexity: O(hlogn) where h is the height of the tree and n is the number of elements in the tree (I am assuming lookup time for each node in logn).

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

Sidebar

Related Questions

I generated this Minimum Spanning Tree using Kruskal algorithm and I have a hard
I have generated a C# SharePoint Sequential Workflow project using the very handy STSDEV
I have generated using openssl mycert.pem which contents the certificate. And I converted the
I have a generated txt file. This file has certain lines that are superfluous,
I have generated code that counts the minimum number of 20's, 10's, 5's, 2's
I have generated a collection of images. Some of them are blank as in
I have generated inputs with price values. Example: <input type=text value=59,00/> Now I should
I have generated a bunch of png files to use as markers on my
I have generated class diagram by gight clicking and selecting generate class diagram usign
i have developed an iphone application where i have generated a terms and condition

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.