• #### Cyclic Directed Graph

What is the complexity of a algorithm of finding the Cyclic Directed Graph?

#### charlypa

• Jun 19th, 2009

Use BFS or DFS time complexity is O(V+E)

• #### How can you traverse a matrix of m lines and n columns in a zig-zag way ?

Example : 1)m = 3,n = 2 a11 a12 a21 a22a31 a32Output : a11 a21 a12 a31 a22 a322) m = 3, n = 4a11 a12 a13 a14a21 a22 a23 a24a31 a32 a33 a34Output : a11 a21 a12 a31 a22 a13 a32 a23 a14 a33 a24 a34

#### Amit Verma

• Feb 21st, 2015

A very basic solution and easy to understand

```Codeint r=0;
for(int i=0;i<row;i++)
{
r=i;
for(int j=0;j<=i;j++)
{
if(j<col)
{
cout<<m[r][j]<<" ";
r--;
}
}

}

int c=0;

for(int i=1;i<=col-1;i++)
{
c=i;
r=row-1;
for(int j=row-1;j>=0;j--)
{
if(c<col)
{

cout<<m[r][c]<<" ";;
r--;
c++;

}
}
}```

#### charlypa

• Jun 19th, 2009

define two varibles initial_x and initial_y define another two varibles x and yint initial_x =  m;int initial_y = n;while (x != m && y! =n){ print (x,y) x--; y++; // Traverse downwar...