A small correction - To access - arr[i][j] => get the memory location by m*i+j.
On Fri, Apr 29, 2011 at 6:25 PM, Anurag Bhatia <[email protected]> wrote: > I have not written code in C for a while, so pardon any gaffes. > > Let us say the dimensions of the array to be created are m and n. > To create the array - (int *)malloc(sizeof(int)*m*n); > To access - arr[i][j] => get the memory location by n*i+j. > > --Anurag > > > > On Fri, Apr 29, 2011 at 6:00 PM, bittu <[email protected]> wrote: >> Basically we have to implement function which allocates memory to a >> two dimensional array. we have to Minimize the number of calls to >> malloc and make sure that the memory is accessible by the notation >> arr[i][j]. >> >> .important part of the question is we have to implement the it using >> single call to MALLOC..its strictly means only 1 time ?? so make sure >> your not calling malloc more then 1 so lets make our hand dirty..?? >> >> Please Read Question Carefully... >> >> >> >> >> >> Thanks & Regrads >> Shashank >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
