by Suresh Khanal
Depth traversal of a tree systematically visits all of its child nodes before visiting any siblings. In case of binary trees, we perform pre-order, in-order or post-order traversal as depth first traversal techniques. Talking about general trees, follow the procedure below to traverse the nodes in depth first fashion.
by Suresh Khanal
Breadth First Search (BFS) Breadth-first-search is a graph search algorithm that begins at the root node (or arbitrarily selected vertex in graph) and explores all the neighboring nodes. Then for each of those nearest nodes it explores their unexplored neighboring nodes, and so on until it finds the goal. With BFS technique, any element is [...]
by Suresh Khanal
This was the first question in Computer Officer Examination in 2010 conducted by Public Service Commission (Lok Sewa Aayog). This question is from the section ‘Data Structures and Algorithms’. The question carries 10 marks. Answer Breadth-first search (BFS) and depth-first search (DFS) are the two algorithms used for traversing and searching a node in a [...]