retagged by
456 views
1 votes
1 votes
Consider the vertices V1 and V2 that are simultaneously on the function call stack at some point during the execution of depth­first search from vertex s in a digraph. Which of the following must be true?

I. There exist directed path from s to V1 and directed path from s to V2 .

II. There exist both a directed path from V1 to V2 and a directed path from V2 to V1

III. If there is no directed path from V1 to V2 then there exist a directed path from V2 to V1 .

The number of above statements is/are true ________ .
retagged by

2 Answers

1 votes
1 votes

To solve such questions, try to take just opposite of the condition asked in options, and try to satisfy the conditions asked in question. 

Conditions in question: 

1. DFS started from vertex s.

2. V1 and V2 are simultaneously on the stack. (No order given).

------------------------------------

Option 1st:

I. There exist directed path from s to V1 and directed path from s to V2 .

Note here, they are saying path, not edge.

So, it is true because without path, how did we reach from S to V1 or V2.

//You may say graph is disconnected, but if it is so, then they would not have been on stack at same time.

Option 2nd:

S----->V1------>V2

Here there is no directed path from V2 to V1, but they will be in stack at same time.

Option 3rd:

True, there has to be a path orelse they will not be in stack at same time.

Try drawing different graphs having path from v1 to v2, v2 to v1, not having path between them. And draw stack for that, you will get a clear picture. :)

so, 1st and 3rd are true here.

0 votes
0 votes
1 & 3 are true.
Answer:

Related questions

1 votes
1 votes
1 answer
1
kamakshi asked Nov 18, 2017
1,360 views
Caption
2 votes
2 votes
2 answers
2
sumit chakraborty asked Jan 11, 2018
1,280 views
If DFS algorithm applied starting from vertex ‘A’ which uses stack data structure then the height of stack is needed in worst case for DFS traversal is _________.
0 votes
0 votes
1 answer
3
Shubhanshu asked Mar 13, 2017
320 views
how many of the above statements are true?