## Help authour, Buy PDF Ebook
>>>**Click Here**<<<

## Data Structure Questions and Answers-Non-recursive Depth First Search

## Click on any option to know the CORRECT ANSWERS

Question 1 |

Which of the following data structure is used to implement DFS?

linked list | |

tree | |

stack | |

queue |

**Puzzles Questions answers**

Question 1 Explanation:

Stack is used in the standard implementation of depth first search. It is used to store the elements which are to be explored.

Question 2 |

Which of the following traversal in a binary tree is similar to depth first traversal?

level order | |

post order | |

pre order | |

in order |

**Microbiology Questions answers**

Question 2 Explanation:

In DFS we keep on exploring as far as possible along each branch before backtracking. It terminates when all nodes are visited. So it is similar to pre order traversal in binary tree.

Question 3 |

What will be the result of depth first traversal in the following tree?

4 2 5 1 3 | |

1 2 4 5 3 | |

4 5 2 3 1 | |

1 2 3 4 5 |

**Current affairs Questions answers**

Question 3 Explanation:

Depth first search is similar to pre order traversal in a tree. So here we will get the same result as for the pre order traversal (root, left right).

Question 4 |

Which of the following is a possible result of depth first traversal of the given graph(consider 1 to be source element)?

1 2 3 4 5 | |

1 2 3 1 4 5 | |

1 4 5 3 2 | |

1 4 5 1 2 3 |

**English literature Questions answers**

Question 4 Explanation:

As 1 is the source element so it will be considered first. Then we start exploring the vertices which are connected to 1. So there will be two possible results-1 2 3 4 5 and 1 4 5 2 3.

Question 5 |

Which of the following represent the correct pseudo code for non recursive DFS algorithm?

procedure DFS-non....recursive(G, v): //let St be a stack St.push(v) while St is not empty v = St.pop() if v is not discovered: label v as discovered for all adjacent vertices of v do St.push(a) | |

procedure DFS-non....recursive(G, v): //let St be a stack St.pop() while St is not empty v = St.push(v) if v is not discovered: label v as discovered for all adjacent vertices of v do St.push(a) / | |

procedure DFS-non....recursive(G, v): //let St be a stack St.push(v) while St is not empty v = St.pop() if v is not discovered: label v as discovered for all adjacent vertices of v do St.push(v) | |

procedure DFS-non....recursive(G, v): //let St be a stack St.pop(v) while St is not empty v = St.pop() if v is not discovered: label v as discovered for all adjacent vertices of v do St.push(a) // |

**Biology Questions answers**

Question 5 Explanation:

In the iterative approach we first push the source node into the stack. If the node has not been visited then it is printed and marked as visited. Then the unvisited adjacent nodes are added to the stack. Then the same procedure is repeated for each node of the stack.

There are 5 questions to complete.