Ad

Tuesday, 2 July 2013

Algo#32: Generate spiral matrix or helical matrix.

It seems very easy problem of just printing 2D matrix in some format. But it includes many corner cases which needs to be taken care of. Such problems can test your coding practice.

Following is implementation of above problem in c language.





Please write comments if you find anything wrong or you want to add something more related to this topic.

Monday, 1 July 2013

Algo#31: Find nth node in inorder traversal.

Given problem of finding nth node in in-order traversal can be easily done if we keep count of nde visited while doing in-order traversal. We will do keep this counter as static rather than global. Though taking static variable are also not encouraged in general because of parallel programming. But as of now in our case it will do.

Following is implementation of above algorithm in c language.





Please write comments if you find anything wrong or you want to add something more related to this topic.

Ad