Breadth First Search (BFS) is started on a binary tree beginning from the root vertex. There is a vertex at a distance four from the root. If is the vertex in this BFS traversal, then the maximum possible value of is __________
GATE CSE 2016Algorithms › Graph AlgorithmsVerified
GATE CSE 2016 PYQ: Breadth First Search (BFS) is started on a binary tree beginning from the root vertex. There is a vertex t t…
Answer
31
Approach
BFS visits vertices level by level. To maximize the position of the depth-4 vertex t, make all levels above t as full as possible and arrange BFS so that t is the last vertex visited at its own level.
The maximum BFS position of a depth-4 vertex is obtained by counting all possible vertices in levels 0 through 3 plus all 16 possible vertices at level 4, giving 31.
Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.