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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started