E.g., from http://en.wikipedia.org/wiki/Tree_(graph_theory)
Definitions: A tree is an undirected simple graph G that satisfies any
of the following equivalent conditions:
G is connected and has no simple cycles.
G has no simple cycles, and a simple cycle is formed if any edge is
added to G.
G is connected, and it is not connected anymore if any edge is removed
from G.
G is connected and the 3-vertex complete graph K3 is not a minor of
G.
Any two vertices in G can be connected by a unique simple path.
Dave
This is simple. Traverse the graph, marking each node as you visit it.
If an edge from the current node connects to a marked node, delete the
edge.
Dave
This would require that a flag be added to each node. Is there a way to
do it without modifying the Data Structure?
--
Prashanth Mohan
http://prashblog.com
I am not sure about the whcih language you use for coding
Steps:
1. Implement a recursive function which traverse the BST (the left
child and right child) it could be any thing like inorder, or
preorder
2. Once you visit a node strore the current node, and corrupt that
node at each visit
3. When the loop occurs, you can not access that node ... it may
through some exception(because you already visited that node and you
currupted it).
4. Remove that loop pointer.
5. Recursively construct the corrupted nodes.
I think this is a stupid logic........ ; )
Thanks,
Praveen.
Dave
Regards,
Gowri Kumar
Hence the solution might work.
OTOH, how do you insert duplicate values into BST?
In particular, if the node value is the same, do you insert to the
left or right?
Regards,
Gowri Kumar