Skip to main content
Included a description of the greedy algorithm
Source Link
John L.
  • 39.1k
  • 4
  • 34
  • 91

Find set ofmost vertices A in a givendirected tree T under paths conditionwhere no path of length less than 3 connects any pair

I've faced this question as an exercise in my homework and I hope for help.

Given a directed tree $T = (V, E)$, Wewe need to find a set of vertices $A \subseteq V$ such that for every two vertices $v,u \in A$ that have aeither there is no path between them, the length of or the path between them is greater than 2of length at least 3. Furthermore, $A$ has toshould contain the maximummaximum number of vertices that satisfies what's written above.

So the point hereThe above is that if there are two vertices $v,u\in A$ and there isn'tan exercise in my homework. "A directed tree" means a path between them then it's still legal vertices,rooted tree where all edges are directed away from the condition here isroot. Note that if there is a path we need its length to be at least 3vertex in $T$ might have more than 2 children.

 

I think the approach here is Dynamic Programming since the graph given is a tree so we don't haveWe can use dynamic programming to check if there'scompute such a path between vertex and its children because is whatset for the tree implementssubtree rooted at each vertex of $T$. However, meaning there's no needI found a simple greedy algorithm.

  1. Create an empty set $A$.
  2. As long as $V\neq \emptyset$, repeat the following action.
    1. Add all leaves to $A$.
    2. Remove their parents and their grandparents from $V$ (and the edges that are connected to them from $E$).
  3. Return $A$.

It's easy to use $BFS$ or $DFS$ or any ofverify that all vertices added satisfy the known algorithmspath separating condition.

Note: The tree hasn't to be a binary tree, so every vertex can have multiple children and not only 2 I believe that the number of all vertices added is optimal. It is indeed true in all cases that I have tried. Is it true? Does the greedy algorithm always work? I would like to see a proof for it.

Find set of vertices A in a given tree T under paths condition

I've faced this question as an exercise in my homework and I hope for help.

Given a directed tree $T = (V, E)$, We need to find a set of vertices $A \subseteq V$ such that for every two vertices $v,u \in A$ that have a path between them, the length of the path is greater than 2. $A$ has to contain the maximum number of vertices that satisfies what's written above.

So the point here is that if there are two vertices $v,u\in A$ and there isn't a path between them then it's still legal vertices, the condition here is that if there is a path we need its length to be at least 3.

I think the approach here is Dynamic Programming since the graph given is a tree so we don't have to check if there's a path between vertex and its children because is what the tree implements, meaning there's no need to use $BFS$ or $DFS$ or any of the known algorithms.

Note: The tree hasn't to be a binary tree, so every vertex can have multiple children and not only 2

Find most vertices in a directed tree where no path of length less than 3 connects any pair

Given a directed tree $T = (V, E)$, we need to find a set of vertices $A \subseteq V$ such that for every two vertices $v,u \in A$ either there is no path between them or the path between them is of length at least 3. Furthermore, $A$ should contain the maximum number of vertices.

The above is an exercise in my homework. "A directed tree" means a rooted tree where all edges are directed away from the root. Note that a vertex in $T$ might have more than 2 children.

 

We can use dynamic programming to compute such a set for the subtree rooted at each vertex of $T$. However, I found a simple greedy algorithm.

  1. Create an empty set $A$.
  2. As long as $V\neq \emptyset$, repeat the following action.
    1. Add all leaves to $A$.
    2. Remove their parents and their grandparents from $V$ (and the edges that are connected to them from $E$).
  3. Return $A$.

It's easy to verify that all vertices added satisfy the path separating condition.

I believe that the number of all vertices added is optimal. It is indeed true in all cases that I have tried. Is it true? Does the greedy algorithm always work? I would like to see a proof for it.

added 79 characters in body
Source Link
Mohamad S.
  • 469
  • 2
  • 13

I've faced this question as an exercise in my homework and I hope for help.

Given a directed tree $T = (V, E)$, We need to find a set of vertices $A \subseteq V$ such that for every two vertices $v,u \in A$ that have a path between them, the length of the path is greater than 2. $A$ has to contain the maximum number of vertices that satisfies what's written above.

So the point here is that if there are two vertices $v,u\in A$ and there isn't a path between them then it's still legal vertices, the condition here is that if there is a path we need its length to be at least 3.

I think the approach here is Dynamic Programming since the graph given is a tree so we don't have to check if there's a path between vertex and its children because is what the tree implements, meaning there's no need to use $BFS$ or $DFS$ or any of the known algorithms.

Note: The tree hasn't to be a binary tree, so every vertex can have multiple children and not only 2

Given a directed tree $T = (V, E)$, We need to find a set of vertices $A \subseteq V$ such that for every two vertices $v,u \in A$ that have a path between them, the length of the path is greater than 2. $A$ has to contain the maximum number of vertices that satisfies what's written above.

So the point here is that if there are two vertices $v,u\in A$ and there isn't a path between them then it's still legal vertices, the condition here is that if there is a path we need its length to be at least 3.

I think the approach here is Dynamic Programming since the graph given is a tree so we don't have to check if there's a path between vertex and its children because is what the tree implements, meaning there's no need to use $BFS$ or $DFS$ or any of the known algorithms.

Note: The tree hasn't to be a binary tree, so every vertex can have multiple children and not only 2

I've faced this question as an exercise in my homework and I hope for help.

Given a directed tree $T = (V, E)$, We need to find a set of vertices $A \subseteq V$ such that for every two vertices $v,u \in A$ that have a path between them, the length of the path is greater than 2. $A$ has to contain the maximum number of vertices that satisfies what's written above.

So the point here is that if there are two vertices $v,u\in A$ and there isn't a path between them then it's still legal vertices, the condition here is that if there is a path we need its length to be at least 3.

I think the approach here is Dynamic Programming since the graph given is a tree so we don't have to check if there's a path between vertex and its children because is what the tree implements, meaning there's no need to use $BFS$ or $DFS$ or any of the known algorithms.

Note: The tree hasn't to be a binary tree, so every vertex can have multiple children and not only 2

added 91 characters in body
Source Link
Mohamad S.
  • 469
  • 2
  • 13

Given a directed tree $T = (V, E)$, We need to find a set of vertices $A \subseteq V$ such that for every two vertices $v,u \in A$ that have a path between them, the length of the path is greater than 2. $A$ has to contain the maximum number of vertices that satisfies what's written above.

So the point here is that if there are two vertices $v,u\in A$ and there isn't a path between them then it's still legal vertices, the condition here is that if there is a path we need its length to be at least 3.

I think the approach here is Dynamic Programming since the graph given is a tree so we don't have to check if there's a path between vertex and its children because is what the tree implements, meaning there's no need to use $BFS$ or $DFS$ or any of the known algorithms.

Note: The tree hasn't to be a binary tree, so every vertex can have multiple children and not only 2

Given a directed tree $T = (V, E)$, We need to find a set of vertices $A \subseteq V$ such that for every two vertices $v,u \in A$ that have a path between them, the length of the path is greater than 2.

So the point here is that if there are two vertices $v,u\in A$ and there isn't a path between them then it's still legal vertices, the condition here is that if there is a path we need its length to be at least 3.

I think the approach here is Dynamic Programming since the graph given is a tree so we don't have to check if there's a path between vertex and its children because is what the tree implements, meaning there's no need to use $BFS$ or $DFS$ or any of the known algorithms.

Note: The tree hasn't to be a binary tree, so every vertex can have multiple children and not only 2

Given a directed tree $T = (V, E)$, We need to find a set of vertices $A \subseteq V$ such that for every two vertices $v,u \in A$ that have a path between them, the length of the path is greater than 2. $A$ has to contain the maximum number of vertices that satisfies what's written above.

So the point here is that if there are two vertices $v,u\in A$ and there isn't a path between them then it's still legal vertices, the condition here is that if there is a path we need its length to be at least 3.

I think the approach here is Dynamic Programming since the graph given is a tree so we don't have to check if there's a path between vertex and its children because is what the tree implements, meaning there's no need to use $BFS$ or $DFS$ or any of the known algorithms.

Note: The tree hasn't to be a binary tree, so every vertex can have multiple children and not only 2

Source Link
Mohamad S.
  • 469
  • 2
  • 13
Loading