The Gateway to Computer Science Excellence
0 votes
192 views

 

in Programming by Loyal (7k points) | 192 views
0
is it (B) 5,7 ??
0
B) 5,7 ?

there may be more answer such as 1,5

and 4,7  etc

but 5,7 matching to the option
0
explain pls?
0
what is the meaning of not pushed in?
0
@himgta
when we want explore any node first we push them into the stack
and if the connected node of that node is already visited than there is no need to push that node into the stack
ex if the connected node of node A is already visited then there is no need to push A into the stack
0
but if we push the every node exactly once in order to traverse it...isin't it?

can u post the detailed solution of the question?
0
himgta wait until asker conferm answer
0
The answer is 5,7.

The question is little bit wrong or may be ambiguous. What i did is :-

First create a graph out of it and when you'll do the DFS of it you'll find in most of the case the vertex 5 or 7 will be at top of stack at will be then popped for backtracking they never go within the stack. So intuitively i answered like that.

The solution doesn't contain anything they simply give the answer. That is as far i know.

Please point out some mistake here :)
0
that's correct...i also got 5,7 by same procedure.
0
I am getting C as answer , there is no braching at V4, V5 and V7.
0
DFS traversal will be like:- $V_6$->$V_3$->$V_1$->$V_2$->$V_4$->$V_8$
0
I am just getting vertex 4
0
0
c is the right answer acording to ace test series.
0
I'm getting everything into the stack, this is my order 6-> 8-> 7-> 3-> 1->2->5->4
0
0
The solution is ambiguous, If you follow the algorithm given on geeksforgeeks,

Each vertex is pushed at least once into the stack,Then how could you find the answer
0

@Gurdeep Saini Do you have any reference for your statement above on not pushing an unbranched node into the stack ?

0

@Shivam Kasat it is he way of implementing the DFS algo , i.e.

when we want explore any node first we push them into the stack
and if the connected node of that node is already visited than there is no need to push that node into the stack
ex if the connected node of node A is already visited then there is no need to push A into the stack

0
implement it on note book then three case arise

1) 5,4 not pushed

2) 4,7 not pushed

3) 5,7 not pushed

and the given answer is the combination of all these

Please log in or register to answer this question.

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,352 answers
198,472 comments
105,244 users