0 votes 0 votes BFS algo is applied on graph as well as Binary tree. So, is it different for both graph and Binary tree? As on youtube some people showing BFS on graph and some on Binary tree. Kindly clarify, thanks! Algorithms algorithms breadth-first-search + – iarnav asked May 29, 2017 iarnav 966 views answer comment Share Follow See 1 comment See all 1 1 comment reply mrinmoyh commented Jan 21, 2020 reply Follow Share BFS tree produced due to BFS on a Binary tree is the Binary tree itself. 0 votes 0 votes Please log in or register to add a comment.
Best answer 3 votes 3 votes One difference between graphs and trees is that graph may contain cycle. So,when we use BFS algorithm for trees there is no problem. //No cycle But when we use it for graph we need to check for cycles. // cycle can be present For example you can refer link: http://www.geeksforgeeks.org/breadth-first-traversal-for-a-graph/ Angkit answered May 29, 2017 • selected Jun 6, 2017 by Tauhin Gangwar Angkit comment Share Follow See all 2 Comments See all 2 2 Comments reply iarnav commented May 29, 2017 reply Follow Share Thanks Ang' as always! blessed be. 0 votes 0 votes Angkit commented May 30, 2017 reply Follow Share Welcome .. :-) 0 votes 0 votes Please log in or register to add a comment.