Depth-first search dfs and breath-first search bfs graph traversal algorithms are applied to a rectangular grid of size n times n. The vertices of the rectangular grid have the form (i,j), where i,j=1,2,3,…,n, and the edges connect pairs (i,j), (i+1,j) and (i,j), (i,j+1). What are the maximal number of vertices occurring inside the stack of the dfs and inside the queue of bfs during execution? How many back arcs are in the case of the dfs are there? How many cross arcs in the case of the bfs are there? Draw the spanning trees for both algorithms in the case n=4. Assume lexicographic ordering of vertices, I.E. (i1,j1) < (i2,j2) if and only if i1 < i2 or (i1 = i2 and j1 < j2).

**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**;

**procedure** bfs(v: vertex);

** var**

x,y: vertex;

Q: QUEUE of vertex;

**begin**

mark[v] := visited;

ENQUEUE(v,Q);

**while not** EMPTY(Q) **do begin**

x := FRONT(Q);

DEQUEUE(Q);

**for** each vertex y inside L[x] **do**

**if** mark[y] := unvisited **then begin**

mark[y] := visited;

ENQUEUE(y,Q)

**end**

** end **

** end;**