Re: [algogeeks] Microsoft Interview Question

2012-10-17 Thread Navin Kumar
@rahul: I got my fault. I didn't thought about that test case. I am
thinking about applying DFS traversal algorithm for graph here. It may work
here.

On Wed, Oct 17, 2012 at 9:01 AM, Rahul Kumar Patle <
patlerahulku...@gmail.com> wrote:

> @navin: still i am not getting your solution.. can you make more clear it
> pls..
>
> here is my doubt..
>
> take input matrix and one temp visited matrix which stores the visited
> path.
> eg:
> 1  1  0  0  0
> 1  1  0  0  0
> 0  1  1  1  0
> 0  1  1  1  0
> 0  0  1  1  1
>
> Suppose i want to find the number of paths between M[4][2] -> M[0][0]
> First i explore path M[4][2]->M[4][3]->M[3][3] and so on... your program
> set 1 on visited matrix... on corresponding V[i][j] entries
> next time i explore the path  M[4][2]->M[3][2]->M[3][3]... but here we
> found that V[3][3]=1 so we can't take this in put path... but actually both
> are different paths..
> how you will ensure this. because we are maintaining only one visited
> matrix.
>
>
>
>
>
>
> On Wed, Oct 17, 2012 at 7:54 AM, Navin Kumar wrote:
>
>> @Rahul: Loop won't occur because when you are visiting any matrix element
>> then you are marking 1 in visited matrix. So second time it will be seen as
>> a already visited element and it will choose another element (or path if
>> exist) or will blocked.
>>
>> On Tue, Oct 16, 2012 at 9:31 AM, Rahul Kumar Patle <
>> patlerahulku...@gmail.com> wrote:
>>
>>> @atul: in your solution object only can move down or right direction. but
>>> in my problem object is free to move in any direction and hence there
>>> are chances of cycle.. how to memoize cycle.
>>> if there is cycle then your approach will give infinite solution.
>>>
>>> consider this maze
>>> 1  1  0  0  0
>>> 1  1  0  0  0
>>> 0  1  1  0  0
>>> 0  1  1  0  0
>>> 0  0  1  1  1
>>>
>>> you can see that object can take path
>>> M[0][0] -> M[0][1] -> M[1][1]-> M[1][2]-> M[][]-> M[][]
>>> OR
>>> M[0][0] -> M[1][0] -> M[1][1]-> M[1][2]-> M[][]-> M[][]
>>> But simple approach will also take path
>>> M[0][0] -> M[0][1] -> M[1][1]-> M[1][0]-> M[0][0]-> M[0][1]  --
>>> CYCLE
>>>
>>> how you will avoid these cycles...
>>>
>>> On Tue, Oct 16, 2012 at 8:58 AM, atul anand wrote:
>>>
 http://www.geeksforgeeks.org/archives/13376


 On Tue, Oct 16, 2012 at 8:56 AM, atul anand wrote:

> can be done simply by backtracking .
>
> On Sat, Oct 13, 2012 at 12:31 AM, Rahul Kumar Patle <
> patlerahulku...@gmail.com> wrote:
>
>> Pls help to solve this que.. does any one have DP solution for following
>> que.
>>
>> http://www.geeksforgeeks.org/archives/24488
>> section 5/question 2
>>
>> Write a program to find all the possible paths from a starting point
>> to dest point in a maze(2-D array).
>>
>> ex:  1 0 1 0
>>  1 1 1 1
>>  0 1 0 1
>>  0 0 1 1
>>
>> If there is a block it’s represented by 0.
>> If there is a path it’s represented by 1.
>>
>>
>>
>> --
>> Thanks and Regards:
>> Rahul Kumar Patle
>> M.Tech, School of Information Technology
>> Indian Institute of Technology, Kharagpur-721302, 
>> India
>> Mobile No: +91-8798049298, +91-9424738542
>> Alternate Email: rahulkumarpa...@hotmail.com
>> [image: 
>> Linkedin]
>> [image: Twitter] 
>> 
>>
>>  --
>> You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group.
>> 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.
>>
>
>
  --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 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.

>>>
>>>
>>>
>>> --
>>> Thanks and Regards:
>>> Rahul Kumar Patle
>>> M.Tech, School of Information Technology
>>> Indian Institute of Technology, Kharagpur-721302, 
>>> India
>>> Mobile No: +91-8798049298, +91-9424738542
>>> Alternate Email: rahulkumarpa...@hotmail.com
>>> [image: 
>>> Linkedin]
>>> [image: Twitter] 
>>> 
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from t

[algogeeks] substring in big string

2012-10-17 Thread Ashish Goel
there is a big string which needs 2GB memory to fit in but you have only
100mb. Find a substring in the big string.

Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
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] C output

2012-10-17 Thread Vikas Kumar
#include
int main()
{
   char str[]={'a','b','c'};
   char str1[]={"abc"};
  printf("%d",sizeof(str));
printf("%d",sizeof(str1));
getchar();
}

This is giving 3 in case of str and 4 in case of str1 bcz str is "array of
character" and str1 is a "string".
For understanding this point consider a integer array int arr[] =
{1,2,3,4}; then for this sizeof(arr) is 16 means 4*sizeof(int). So in the
same way for str in given program it is giving 3*sizeof(char) i.e. 3.

sizeof(anyString) = lengthOfString +1 ( +1 for '\0')
strlen(anyString)  = simple length
sizeof(anyArray) = numberofElementPresentInArray*sizeof(dataType)


-- 
*Thanks,*
*Vikas Kumar*
*
*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
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.