Question: Depth-first search algorithm is applied to a full binary tree of height k. Assume that the edges are directed from parents to children. What is

Depth-first search algorithm is applied to a full binary tree of height k. Assume that the edges are directed from parents to children. What is the maximal number of vertices occurring inside the stack during the execution? How many times is this maximal size repeated? Assume that the vertices are ordered level-by-levelfrom top to bottom and from left to right inside each level. procedure dfs(v: vertex); var x,y: vertex; S: STACK of vertex; begin mark[v] := visited; PUSH(v,S); while not EMPTY(S) do begin x := TOP(S); if there is an unvisited vertex y inside L[x] then begin mark[y] := visited; PUSH(y,S) end else POP(S) end end;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!