[algogeeks] Re: adobe

2012-07-02 Thread Rishabh Agarwal

nrows: number of rows
ncols: number of columns

int **arra = (int **)malloc( sizeof(int*) * nrows );
int *ar = (int *)malloc( sizeof(int) * nrows * ncols );
for( int a = 0; a  nrows; a ++ ) {
arra[a] = ar + ncols * a;
}

now index of array i and j can be accessed as arra[i][j]


On Friday, June 29, 2012 4:46:18 PM UTC+5:30, rahul r. srivastava wrote:

 implement a 2d matrix using only 2 mallocs.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/Pr2cEtta_LsJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Microsoft Interview Question

2012-06-21 Thread Rishabh Agarwal
@Abhi: if you apply quick sort then again the order will will not be intact

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/ic2CXJXSGuoJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Reverse Queue

2012-06-20 Thread Rishabh Agarwal
@Navin: as you say you have to take stack or some other data structure 
then it will definately not be donw in O(1) space complexity i think the 
recursive solution is best because we are not explicitly using any extra 
space its internal stack is using this space.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/oKM6PICuD6oJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.