0 votes 0 votes Programming in C depth-first-search data-structures graph-algorithms + – Na462 asked Nov 7, 2018 Na462 1.0k views answer comment Share Follow See all 20 Comments See all 20 20 Comments reply Naveen Kumar 3 commented Nov 7, 2018 reply Follow Share is it (B) 5,7 ?? 0 votes 0 votes Gurdeep Saini commented Nov 7, 2018 reply Follow Share B) 5,7 ? there may be more answer such as 1,5 and 4,7 etc but 5,7 matching to the option 0 votes 0 votes Raghav Khajuria commented Nov 7, 2018 reply Follow Share explain pls? 0 votes 0 votes himgta commented Nov 8, 2018 reply Follow Share what is the meaning of not pushed in? 0 votes 0 votes Gurdeep Saini commented Nov 8, 2018 reply Follow Share @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 votes 0 votes himgta commented Nov 8, 2018 reply Follow Share 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 votes 0 votes Gurdeep Saini commented Nov 8, 2018 reply Follow Share himgta wait until asker conferm answer 0 votes 0 votes Na462 commented Nov 14, 2018 reply Follow Share 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 votes 0 votes Naveen Kumar 3 commented Nov 14, 2018 reply Follow Share that's correct...i also got 5,7 by same procedure. 0 votes 0 votes Shivam Kasat commented Nov 14, 2018 reply Follow Share I am getting C as answer , there is no braching at V4, V5 and V7. 0 votes 0 votes Naveen Kumar 3 commented Nov 14, 2018 reply Follow Share DFS traversal will be like:- $V_6$->$V_3$->$V_1$->$V_2$->$V_4$->$V_8$ 0 votes 0 votes anjali007 commented Dec 9, 2018 reply Follow Share I am just getting vertex 4 0 votes 0 votes Shivam Kasat commented Dec 9, 2018 reply Follow Share @anjali007 https://gateoverflow.in/276438/which-dfs-algorithm-to-follow will you please! check it out, 0 votes 0 votes Shubham Aggarwal commented Dec 9, 2018 reply Follow Share c is the right answer acording to ace test series. 0 votes 0 votes Hemanth_13 commented Dec 9, 2018 reply Follow Share I'm getting everything into the stack, this is my order 6-> 8-> 7-> 3-> 1->2->5->4 0 votes 0 votes Shivam Kasat commented Dec 9, 2018 reply Follow Share https://gateoverflow.in/276438/which-dfs-algorithm-to-follow will anyone help me out with this! 0 votes 0 votes Shivam Kasat commented Dec 9, 2018 reply Follow Share 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 votes 0 votes Shivam Kasat commented Dec 9, 2018 reply Follow Share @Gurdeep Saini Do you have any reference for your statement above on not pushing an unbranched node into the stack ? 0 votes 0 votes Gurdeep Saini commented Dec 11, 2018 reply Follow Share @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 votes 0 votes Gurdeep Saini commented Dec 11, 2018 reply Follow Share 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 0 votes 0 votes Please log in or register to add a comment.