[algogeeks] Indus Valley Partners Paper Pattern

2012-08-18 Thread Arun Kindra
Can anyone know Indus Valley Partners Paper Pattern and ques?

-- 
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.



[algogeeks] Re: Printing random word from file

2012-08-18 Thread Dave
@Navin: Here is the algorithm:
 
Save the first word. 
For i = 2, 3, ..., n = number of words in the file
replace the saved word with the i-th word with probability 1/i.
When EOF is reached, every word in the file will have probability 1/n of 
being the saved word. Print it.
 
Dave

On Saturday, August 18, 2012 1:28:56 AM UTC-5, Navin Kumar wrote:

> Print a *Random word* from a file. Input is "path to a file", 
>
> constraints- No extra memory like hashing etc. All the words in the file 
> should have equal probability.

-- 
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/-/HxO-wNzEP9gJ.
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] is given number is lucky..?

2012-08-18 Thread coolfrog$
@vivek
ur code is give true for 5

The first few numbers of series  are
3, 7, 13, 31, 37, 43, 67, 73, 79, 127, 151, 163, 193.

On Mon, Aug 13, 2012 at 10:15 AM, vivek rungta wrote:

> bool is_lucky(int x){
> int pos=x;
> inr count=2;
> while(count if(pos%count)
> return 0;
> pos=pos-pos/count;
> count++;
> }
> return 1;
>
> }
>
>
>
> On Sun, Aug 5, 2012 at 1:11 PM, dheeraj hasija <
> dheerajhasija1...@gmail.com> wrote:
>
>> @daksh paaji kya baat hai thanks for the solution. aap har jagah hai :P
>>
>>
>> On Sat, Aug 4, 2012 at 12:21 AM, Daksh Talwar wrote:
>>
>>> maintain a bool array of size of limit of int
>>> store true for lucky numbers
>>> and then cross check using the function.
>>> create the bool array like the one they show in the wiki page
>>>
>>>  --
>>> 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.
>>
>
>  --
> 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.
>



-- 
--*
*
Regards
**
*Divesh Dixit*
*Software Developer
Webaroo Technology India Pvt Ltd,
* *cell:* +91-773895195 | +91-8291302034
div...@webaroo.com | www.smsgupshup.com

-- 
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] Re: Interview Question

2012-08-18 Thread abhinav sikri
Hope this helps :
space: o(n^2)
time: o(n^2)

#include
using namespace std;

inline int max(int a,int b)
{
if(a>b)
return a;
else
return b;
}

int main()
{
char str[7]="hello";
int arr[3][3]={
{15,2,3},
{4,5,6},
{7,8,9},
};
int sum[3][3]={0};
int n=3,i,j;
sum[0][0]=arr[0][0];
for(i=1;ik)
min=k;
}
}
cout<<"ans : "
> @Hraday
> worst case complexity of your algorithm comes out to be O(n^4)..
> What I was thinking is precompute sums of all the rectangles in a sum
> matrix ..using dynamic programming because I read some where that sum of
> rectangles in a matrix has an optimal substructure property..
>
> So we can get sum of all the partitioned rectangles in O(1) reducing our
> complexity to O(n^2)..So, our job now is just to precompute the matrix..
>
>
> On Sunday, 12 August 2012 17:48:07 UTC+5:30, sahil taneja wrote:
>
>> Divide 2D array into 4 parts. Compute sum of each partition and get max
>> value from the four of them. For all possible partitions get min value of
>> such max values computed.
>>
>  --
> 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/-/dOI2SIuw-nMJ.
>
> 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.
>



-- 
Abhinav Sikri
B.E. (Computer Engineering)
Netaji Subhas Institute of Technology
Dwarka, New Delhi

-- 
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] file handle

2012-08-18 Thread AISHWARYA KUMAR
I think char written by fputc in the file is goes into the buffer and
written to the file only after closing of the file . I have tried it with
the following code .First two loops print nothing but 3rd one prints A .
that is why last closing file pointer overwrite the content written by
pointer which was closed earlier .
#include
main()
{
FILE *fp1,*fp2,*fp3;
char c;
fp1=fopen("one","w");
fp3=fopen("one","r");
fp2=fopen("one","w");
fputc('A',fp1);
while((c=fgetc(fp3))!=EOF)
printf("%c\n",c);
fputc('B',fp2);
while((c=fgetc(fp3))!=EOF)
printf("%c\n",c);
fclose(fp1);   // stmt 1
while((c=fgetc(fp3))!=EOF)
printf("%c\n",c);
 fclose(fp2);   // stmt 2
}

-- 
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] file handle

2012-08-18 Thread Rahul Kumar Dubey
It is because "fputc()" does not  writes to file directly . All contents
remain in buffer  and as soon as fclose()
is called for that file pointer, buffer content is flushed  to file . so
the file pointer which is closed  last
will overwrite finally  to the file  .
in this case fp2's buffer content will be flushed  last so it will be in
file.
on interchanging two statements "fp1's " buffer content will be flushed
last so it will be in file .

On Sat, Aug 18, 2012 at 5:09 PM, Ratan  wrote:

> #include
> main()
> {
> FILE *fp1,*fp2;
> fp1=fopen("one","w");
> fp2=fopen("one","w");
> fputc('A',fp1);
> fputc('B',fp2);
> fclose(fp1);   // stmt 1
> fclose(fp2);   // stmt 2
> }
>
>
>
> on interchanging the stmt 1 and stmt 2 content of file "one" is also
> changed. how does this happen ... as becauz i am just reversing
> the file closing handle that has nothing to do with writng to the file
> as the file has already been written by fputc() function 
> kindly clarify my confusion..
>
> --
> --
> Ratan | Final Year | Information Technology | NIT ALLAHABAD
>
> --
> 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.
>
>


-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science &Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
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.



[algogeeks] file handle

2012-08-18 Thread Ratan
#include
main()
{
FILE *fp1,*fp2;
fp1=fopen("one","w");
fp2=fopen("one","w");
fputc('A',fp1);
fputc('B',fp2);
fclose(fp1);   // stmt 1
fclose(fp2);   // stmt 2
}



on interchanging the stmt 1 and stmt 2 content of file "one" is also
changed. how does this happen ... as becauz i am just reversing
the file closing handle that has nothing to do with writng to the file
as the file has already been written by fputc() function 
kindly clarify my confusion..

-- 
--
Ratan | Final Year | Information Technology | NIT ALLAHABAD

-- 
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.