C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD

# Please suggest some algorithm to find the node in a tree whose distance to its farthest node is minimum among all the no

By : user3849200
Date : October 23 2020, 03:00 PM
I wish this helpful for you Choose an arbitrary node v in the tree T. Run BFS making v as the root of T. BFS outputs the distances from v to all the other nodes of T.
Now choose a node u that is farthest from v. Run again BFS making u as the root. On the new distance output, find a node w that is farthest from u.
code :

Share :

## Select head node after minimum-weight spanning tree algorithm

By : awscott
Date : March 29 2020, 07:55 AM
I hope this helps . One criteria you can use is the average distance from node to all the other nodes. Choose the node with minimum average distance. You can also probably try average square distance etc.

## Binary search tree method needed: find minimum value node

Date : March 29 2020, 07:55 AM
wish help you to fix your issue As i think that if i gave you the solution you will not learn, i'll give a link to you read more about Binary Search Tree: http://en.wikipedia.org/wiki/Binary_search_tree
After that comment, My way:
code :
``````public T min() {
return recMin(root).getInfo();
}

public BSTnode<T> recMin(BSTnode<T> tree) {
if (tree == null) {
throw new NoSuchElementException();
}
if (tree.left == null) {
return tree;
}
return recMin(tree.left);
}

public T IterationMin(BSTnode<T> tree) {
if (tree == null) {
throw new NoSuchElementException();
}

while (tree.left != null) {
tree = tree.left;
}
return tree.getInfo();
}
``````

## Find distance between root and any node in binary tree

By : dkaj
Date : March 29 2020, 07:55 AM
I wish this helpful for you You are discarding the values returned by recursive calls to add(). Change the calls to:
code :
``````return add(&(*root)->left, bam, pom);
...
``````

## How to find nodes at a distance k from the given node in binary tree

By : user2985048
Date : March 29 2020, 07:55 AM
This might help you Let's say the depth of target node is D.
If the nodes you want is in the subtree rooted with target node, their depth should be D+k. After that, you need to find all ancestors of the target node. For each ancestor, if the depth is d, the distance between this ancestor to the target node is D-d. So the final step is to find nodes in the other subtree of this ancestor whose distance is k - (D-d).

## Get the distance from a root to a node with given value in a binary tree: Algorithm correctness

By : Palo Verde
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , As it stands your code won't work as intended. Consider this on the other hand: