edited by
5,053 views
16 votes
16 votes
Let $T$ be a Depth First Tree of a undirected graph $G$. An array $P$ indexed by the vertices of $G$ is given. $P[V]$ is the parent of vertex $V$, in $T$. Parent of the root is the root itself.

Give a method for finding and printing the cycle formed if the edge $(u,v)$ of $G$ not in $T$ (i.e., $e \in G-T$) is now added to $T$.

Time taken by your method must be proportional to the length of the cycle.

Describe the algorithm in a PASCAL $(C)$ – like language. Assume that the variables have been suitably declared.
edited by

5 Answers

Related questions

23 votes
23 votes
3 answers
3
Kathleen asked Sep 13, 2014
4,669 views
Assume that the last element of the set is used as partition element in Quicksort. If $n$ distinct elements from the set $\left[1\dots n\right]$ are to be sorted, give an...
9 votes
9 votes
3 answers
4
Kathleen asked Sep 12, 2014
7,501 views
Which of the following problems is not $\text{NP}$-hard?Hamiltonian circuit problemThe $0/1$ Knapsack problemFinding bi-connected components of a graphThe graph coloring ...