[algogeeks] Re: Run for a google years

2011-05-10 Thread Dave
@Aamir: First, regarding overflow, 1000  = -128. Thus, the cycle
is 0, 1, 2, ..., 127, -128, -127, ..., -1, and back to 0.

Second, regarding your assertion that you only need a single character
instead of an array of them: Based on the above sequence, every time
a[0] cycles back to 0, p is set to 1. The next step increments a[1].
If that doesn't result in 0, then p is reset to 0, but if it does
result in 0, then p is set to 2, and a[2] will be incremented. This
means that a[0] has reached 0 256 times, so a[0] has been incremented
256^2 = 65,536 times. After a[0] has been incremented 256^3 times, p
will be set to 3. Etc. After a[0] has been incremented 256^49 times, p
will be set to 49 and the loop will be terminated. But 256^49 = 2^392.
But 2^392 nanoseconds exceeds 1 google years.

Dave

On May 10, 4:59 pm, Aamir Khan  wrote:
> On Mon, May 9, 2011 at 8:31 PM, Don  wrote:
> > That would do it if you have a 64-bit type, which most implementations
> > have, but the standard does not require.
> > I think that I can make it shorter and cleaner.
>
> > int main(int argc, char* argv[])
> > {
> >    const int n=49;
> >    char a[n]={0};
>
> I think we can use a single character like char a=0; instead of array of
> characters as ultimately the value is incremented for a[0] only in your
> code.
>
> And i was testing with smaller values of n=1 and found something strange
> like the value of a[p] increases from 0 to 127 (thats normal) but after
> adding 1 to 127 it shows -128..I know that char is of 1byte or 8 bits only
> and after +127 its value will overflow.
>
> I have question regarding the same:
>
> 1) How to calculate the next value in case of overflow. As i tried
> calculating by binary addition and 0111  + 1 = 1000  thats means
> answer should have been -0 or 0.
>
>    int p=0;
>
>
>
>
>
>
>
> >    // This line will run for 10^100 years
> >    for(; p < n; p = ++a[p] ? 0 : p + 1);
>
> >    return 0;
> > }
>
> > The array of 49 bytes provides 392 bits of state, which will take more
> > than the 2^387 cycles available in a google years.
>
> > If the processor takes 9 operations to execute the loop, a value of
> > n=48 would be sufficient.
> > Don
>
> > On May 7, 12:24 pm, Dave  wrote:
> > > @Don: Here is my solution:
>
> > > unsigned long long int a=1;
> > > unsigned long long int b=0;
> > > unsigned long long int c=0;
> > > unsigned long long int d=0;
> > > unsigned long long int e=0;
> > > unsigned long long int f=0;
> > > unsigned long long int g=0;
> > > unsigned long long int h=0;
> > > /* here is the line "/
> > > while(a)if(!++h)if(!++g)if(!++f)if(!++e)if(!++d)if(!++c)if(!++b)++a;
>
> > > My reasoning is as follows: 1 google years ~= 10^116.5 nanoseconds ~=
> > > 2^387. Thus, incrementing an integer of length 387 bits once every
> > > nanosecond should take a google years to overflow. Seven 64-bit
> > > integers provides 448 bits of state.
>
> > > Dave
>
> > > On May 6, 11:25 am, Don  wrote:
>
> > > > What is the shortest single line in a C program which will take more
> > > > than a google years to execute, but will eventually complete? You are
> > > > permitted to have code before or after the line, but execution of the
> > > > code must remain on that line, meaning no function calls, etc. Assume
> > > > a processor which executes 1 billion operations a second.
>
> > --
> > 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.
>
> --
> Aamir Khan
> Indian Institute of Technology Roorkee,
> Roorkee, Uttarakhand,
> India , 247667
> Phone: +91 9557647357
> email:   aami...@iitr.ernet.in 
>             ak4u2...@gmail.com- Hide quoted text -
>
> - Show quoted text -

-- 
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: GOOGLE INTERVIEW QUESTION

2011-05-10 Thread Anders Ma
take “aabab” for example,  the result is "aba, b,a"; however, the
right result is "aa,bab"

On Wed, May 11, 2011 at 10:57 AM, shubham  wrote:
> check this one out:
>
> #include
> #include
> #include
> #include
> using namespace std;
> int check_palin(string str,int *start)
> {
>    int pos=-1,ret,size=str.size()-1;
>    char last_char=str[size];
>    while(pos    {
>        ret=0;int i;
>        pos=str.find(last_char,pos+1);
>        for(i=0;i<=(size-pos);i++)
>          if(str[i+pos]!=str[size-i]) break;
>        if(i==size-pos+1){(*start)=pos;return (size-pos+1);}
>    }
> }
> int main()
> {
>    string arr;
>    vector palin,str;
>    cin>>arr;str.push_back(arr);
>    while(arr!="")
>    {
>        int s=0,e=0,max=0,start=0,end=0,len;
>        string tmp="";
>        for(int i=0;i        {
>            tmp+=arr[i];
>            len=check_palin(tmp,&s);
>            if(len>max){max=len;start=s;}
>        }
>        tmp=arr.substr(start,max);
>        palin.push_back(tmp);str.pop_back();
>        tmp=arr.substr(0,start);if(tmp!="") str.push_back(tmp);
>        tmp=arr.substr(start+max);if(tmp!="") str.push_back(tmp);
>        if(str.size())arr=str[str.size()-1];else arr="";
>    }
>    for(int i=0;i    return 0;
> }
>
> --
> 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
Anders

-- 
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: GOOGLE INTERVIEW QUESTION

2011-05-10 Thread shubham
check this one out:

#include
#include
#include
#include
using namespace std;
int check_palin(string str,int *start)
{
int pos=-1,ret,size=str.size()-1;
char last_char=str[size];
while(pos palin,str;
cin>>arr;str.push_back(arr);
while(arr!="")
{
int s=0,e=0,max=0,start=0,end=0,len;
string tmp="";
for(int i=0;imax){max=len;start=s;}
}
tmp=arr.substr(start,max);
palin.push_back(tmp);str.pop_back();
tmp=arr.substr(0,start);if(tmp!="") str.push_back(tmp);
tmp=arr.substr(start+max);if(tmp!="") str.push_back(tmp);
if(str.size())arr=str[str.size()-1];else arr="";
}
for(int i=0;ihttp://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Fwd: Problems

2011-05-10 Thread pacific :-)
>
>  For the question 4 ,
>>>
>> Choose a nut , try all bolts and then remove the one that fits.Now choose
another nut and try with the rest of the bolts.

Is this the best possible method ?

complexity : best case 0( n )
   worst case 0( n ^ 2)
  average case 0 ( n ^ 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] Re: Extract Top K elements from a List of N elements based on frequency

2011-05-10 Thread Aamir Khan
On Mon, May 9, 2011 at 11:44 AM, Ashish Goel  wrote:

> Dave,
> w.r.t statement, After all integers are processed, compress out the unused
> hash table
> entries and find the Kth largest element,
>
>
> I could not understand the compress concept...are you saying something on
> counting sort philosophy?
> say the list is
>
> 5
> 4
> 4
> 3
> 3
> 3
> 2
> 2
> 2
> 2
> 1
> 1
> 1
> 1
> 1
>
> so the hash map will have
>
> 5,1 <5 is 1 time>
> 4,2,<4 is two time>
> 3,3,...
> 2,4,...
> 1,5...
>
> so if the question is to find say 3rd largest element based on frequency,
> it would be 4
>

3rd largest element based on frequency should be 3 i think?


> This essentially means that we probably need dynamic order statistics where
> the node contains the starting rank for a particular entry in the RBTree.
> Each RBTree node contains the number, its frequency and rank. then this
> becomes O(n) +O(lgn) i.e. O(n)
>
>
>
>
>
>
>
>
>
>
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
>
> On Sat, May 7, 2011 at 11:03 PM, Dave  wrote:
>
>> @Gaurav: As I understand your solution, you are finding the K largest
>> integers based on value, rather than the K with the highest frequency
>> of occurrence.
>>
>> @Amit: Hash the integers into a hash table that includes a field for
>> the frequency count. When a new entry is made, set the frequency count
>> to 1. When an integer already is in the table, increment its count.
>> After all integers are processed, compress out the unused hash table
>> entries and find the Kth largest element. The overall algorithm can be
>> done in O(n).
>>
>> Dave
>>
>> On May 7, 12:06 pm, Gaurav Aggarwal <0007gau...@gmail.com> wrote:
>> > It can be done without sorting. Take the first element as pivot
>> > element. Calculate its position using Partition algorithm.
>> > If its new index is K, then on left side are top K  integers. If
>> index>K,
>> > apply algo on left side Else apply algo on right side.
>> >
>> > Best Case: O(1)
>> > Worst Case: O(n^2)
>> >
>> > But there are very less chances of worst case. It is when the list is
>> > already sorted.
>> >
>> >
>> >
>> >
>> >
>> > On Thu, May 5, 2011 at 1:06 AM, amit  wrote:
>> > > Hi ,
>> >
>> > > We are give a list of integers now our task is to find the top K
>> > > integers in the list based on frequency.
>> >
>> > > Apart from sorting the data can there be any other algorithm?
>> >
>> > > --
>> > > 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.
>> >
>> > --
>> > Gaurav Aggarwal
>> > SCJP- Hide quoted text -
>> >
>> > - Show quoted text -
>>
>> --
>> 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.
>



-- 
Aamir Khan
Indian Institute of Technology Roorkee,
Roorkee, Uttarakhand,
India , 247667
Phone: +91 9557647357
email:   aami...@iitr.ernet.in 
ak4u2...@gmail.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: Run for a google years

2011-05-10 Thread Aamir Khan
On Mon, May 9, 2011 at 8:31 PM, Don  wrote:

> That would do it if you have a 64-bit type, which most implementations
> have, but the standard does not require.
> I think that I can make it shorter and cleaner.
>
> int main(int argc, char* argv[])
> {
>const int n=49;
>char a[n]={0};
>

I think we can use a single character like char a=0; instead of array of
characters as ultimately the value is incremented for a[0] only in your
code.

And i was testing with smaller values of n=1 and found something strange
like the value of a[p] increases from 0 to 127 (thats normal) but after
adding 1 to 127 it shows -128..I know that char is of 1byte or 8 bits only
and after +127 its value will overflow.

I have question regarding the same:

1) How to calculate the next value in case of overflow. As i tried
calculating by binary addition and 0111  + 1 = 1000  thats means
answer should have been -0 or 0.

   int p=0;
>
>// This line will run for 10^100 years
>for(; p < n; p = ++a[p] ? 0 : p + 1);
>
>return 0;
> }
>
> The array of 49 bytes provides 392 bits of state, which will take more
> than the 2^387 cycles available in a google years.
>
> If the processor takes 9 operations to execute the loop, a value of
> n=48 would be sufficient.


> Don
>
> On May 7, 12:24 pm, Dave  wrote:
> > @Don: Here is my solution:
> >
> > unsigned long long int a=1;
> > unsigned long long int b=0;
> > unsigned long long int c=0;
> > unsigned long long int d=0;
> > unsigned long long int e=0;
> > unsigned long long int f=0;
> > unsigned long long int g=0;
> > unsigned long long int h=0;
> > /* here is the line "/
> > while(a)if(!++h)if(!++g)if(!++f)if(!++e)if(!++d)if(!++c)if(!++b)++a;
> >
> > My reasoning is as follows: 1 google years ~= 10^116.5 nanoseconds ~=
> > 2^387. Thus, incrementing an integer of length 387 bits once every
> > nanosecond should take a google years to overflow. Seven 64-bit
> > integers provides 448 bits of state.
> >
> > Dave
> >
> > On May 6, 11:25 am, Don  wrote:
> >
> > > What is the shortest single line in a C program which will take more
> > > than a google years to execute, but will eventually complete? You are
> > > permitted to have code before or after the line, but execution of the
> > > code must remain on that line, meaning no function calls, etc. Assume
> > > a processor which executes 1 billion operations a second.
> >
> >
>
> --
> 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.
>
>


-- 
Aamir Khan
Indian Institute of Technology Roorkee,
Roorkee, Uttarakhand,
India , 247667
Phone: +91 9557647357
email:   aami...@iitr.ernet.in 
ak4u2...@gmail.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.



[algogeeks] Re: MATHS TRICK TEASER 9 may

2011-05-10 Thread Dave
19 = XIX in Roman Numerals. Take 1 = I away and you have XX = 20.

Dave

On May 10, 2:09 am, Lavesh Rawat  wrote:
> *MATHS TRICK TEASER
>  *
> *
> *
> **
> *Prove that taking away 1 from 19 makes 20.
> *
>
> *Update Your Answers at* : Click
> Here
>
> Solution:
> Will be updated after 1 day
>
> --
>
>                     "Never explain yourself. Your friends don’t need it and
> your enemies won’t believe it" .

-- 
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] Need the algorithm or idea

2011-05-10 Thread pacific :-)
You may have to use a trie and also the edit distance for this problem.

Firstly , walk down the trie as you can keep matching the alphabets.
When you encounter a first mismatch , findout the edit distance for the rest
of the substring of the input with all of the strings possible from that
node down to the leaves.
Now output the one with the least edit distance as the correct spelling.
You might want to keep a bound on the max edit distance and say no
suggestions if edit distance exceeds that.


On Tue, May 3, 2011 at 9:47 AM, Sathaiah Dontula wrote:

> is it not EDIT DISTANCE  (DP) problem ?
>
> Thanks & regards,
> Sathaiah Dontula
>
>
> On Tue, May 3, 2011 at 9:03 AM, lichenga2404 wrote:
>
>> The question in an interview. And I got lost with this one.
>>
>> Could you guys give some algorithm or idea on  this ?
>>
>>
>> Write a program that reads a large list of English words (e.g. from /
>> usr/share/dict/words on a unix system) into memory, and then reads
>> words from stdin, and prints either the best spelling suggestion, or
>> "NO SUGGESTION" if no suggestion can be found. The program should
>> print ">" as a prompt before reading each word, and should loop until
>> killed.
>>
>> Your solution should be faster than O(n)
>>
>> For example:
>>
>> > shep
>> sheep
>> > peepple
>> people
>> > sheeple
>> NO SUGGESTION
>> The class of spelling mistakes to be corrected is as follows:
>>
>> Case (upper/lower) errors: "inSIDE" => "inside"
>> Repeated letters: "jjoobbb" => "job"
>> Incorrect vowels: "weke" => "wake"
>> Any combination of the above types of error in a single word should be
>> corrected (e.g. "CUNsperrICY" => "conspiracy").
>>
>> If there are many possible corrections of an input word, your program
>> can choose one in any way you like. It just has to be an English word
>> that is a spelling correction of the input by the above rules.
>>
>> Final step: Write a second program that *generates* words with
>> spelling mistakes of the above form, starting with correctly spelled
>> English words. Pipe its output into the first program and verify that
>> there are no occurrences of "NO SUGGESTION" in the output
>>
>> --
>> 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,
chinna.

-- 
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: Amazon Interview Question

2011-05-10 Thread pacific :-)
My approach :

 Have a pointer to the start (smallest of the array) of each of the N
arrays.
 Until all pointers reach end of respective arrays :
take the smallest value from all of the pointers
and compute the difference between the smallest and the current pointers
of each of the arrays
let newdiff be the smallest among all the diffs
if newdiff < olddiff :
   olddiff = newdiff
   only advance the smallest number pointer

Correctness :

I believe that if the smallest difference occurs between a and b ,(a is
smallest) you will come across that comparison and find the least.

Complexity : 0(kn) , it should be the best because you atleast need to read
all of the input.

Please correct me if i'm wrong.


On Mon, May 9, 2011 at 8:55 PM, bittu  wrote:

> see here & let me know if anything wrong..??
>
>
> http://shashank7s.blogspot.com/2011/05/wap-to-find-minimum-difference-between.html
>
>
>
> Thanks & Regrads
> Shashank >> " the Best Way to Escape From The problem is to Solve it"
> Computer Science & Engg.
> BIT Mesra
>
> --
> 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,
chinna.

-- 
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] GOOGLE INTERVIEW QUESTION

2011-05-10 Thread Senthil S
Hello Anders Ma .. for inputs like "iiestseig" (just a random string) your
code will not produce the correct output .. cos the best possible way to
split these strings is {"i","iestsei","g"} .. But your code will produce
{"ii","este","i","g"} as output .. so when there are overlapping palindromes
your code wont produce the correct output .. please look into it ..

On Tue, May 10, 2011 at 8:03 AM, Anders Ma  wrote:

> #include 
> #include 
>
> int is_palindrome(char* string, int start, int end)
> {
>int i = start, j = end;
>
>while (start <= end) {
>if (string[start++] != string[end--])
>return 0;
>}
>
>/* print */
>printf("[%d,%d] ", i, j);
>while ( i <= j)
>printf("%c", string[i++]);
>printf("\n");
>
>return 1;
> }
>
> int main(int argc, char** argv)
> {
>int i, j, k;
> int len, rescan;
>char demo[] = "madamimadam";
> char *p;
>
>if (argc != 2) {
>printf("usage padin (string)\n");
>return 0;
>}
>p = argv[1];
>
> do {
>rescan = 0;
>len = strlen(p);
>for (i = 0; i < len && rescan == 0; i++) {
> for (j = i, k = len; j <= k; k--)
>if (is_palindrome(p, j, k)) {
>p += k - j + 1;
> rescan = 1;
>break;
>}
>}
>} while (rescan);
>
>return 0;
> }
> anders@ubuntu:~/c$ gcc palindrome.c -o palin
> anders@ubuntu:~/c$ ./palin helloworld
> [0,0] h
> [0,0] e
> [0,1] ll
> [0,2] owo
> [0,0] r
> [0,0] l
> [0,0] d
> anders@ubuntu:~/c$ ./palin madamimadam
> [0,10] madamimadam
> anders@ubuntu:~/c$ ./palin andersma
> [0,0] a
> [0,0] n
> [0,0] d
> [0,0] e
> [0,0] r
> [0,0] s
> [0,0] m
> [0,0] a
>
>
> On Tue, May 10, 2011 at 10:11 AM, oldman 
> wrote:
> > I agree with Anders Ma's point,but in my opinion, using goto is risky in
> a
> > import interview
> >
> > On Tue, May 10, 2011 at 9:52 AM, Anders Ma  wrote:
> >>
> >>  sometimes we need goto, goto is not so evil.
> >>
> >> On Tue, May 10, 2011 at 2:49 AM, Manjeet Chayel
> >>  wrote:
> >> > Dont use goto... its not good to have it.
> >> >
> >> > On Mon, May 9, 2011 at 2:44 PM, Anders Ma 
> wrote:
> >> >>
> >> >> #include 
> >> >> #include 
> >> >>
> >> >> int is_palindrome(char* string, int start, int end)
> >> >> {
> >> >>int i = start, j = end;
> >> >>
> >> >>while (start <= end) {
> >> >>if (string[start++] != string[end--])
> >> >>return 0;
> >> >>}
> >> >>
> >> >>/* print */
> >> >>printf("[%d,%d] ", i, j);
> >> >>while ( i <= j)
> >> >>printf("%c", string[i++]);
> >> >>printf("\n");
> >> >>
> >> >>return 1;
> >> >> }
> >> >>
> >> >> int main(int argc, char** argv)
> >> >> {
> >> >>int i, j, k;
> >> >>int len;
> >> >>char *p;
> >> >>
> >> >>if (argc != 2) {
> >> >>printf("usage padin (string)\n");
> >> >>return 0;
> >> >>}
> >> >>p = argv[1];
> >> >> BEGIN:
> >> >>
> >> >>len = strlen(p);
> >> >>for (i = 0; i < len; i++) {
> >> >>for (j = i, k = len; j <= k; k--)
> >> >>if (is_palindrome(p, j, k)) {
> >> >>p += k - j + 1;
> >> >>goto BEGIN;
> >> >>}
> >> >>}
> >> >>
> >> >>return 0;
> >> >> }
> >> >>
> >> >> anders@ubuntu:~/c$ ./palin helloworld
> >> >> [0,0] h
> >> >> [0,0] e
> >> >> [0,1] ll
> >> >> [0,2] owo
> >> >> [0,0] r
> >> >> [0,0] l
> >> >> [0,0] d
> >> >> anders@ubuntu:~/c$ ./palin madamamadam
> >> >> [0,10] madamamadam
> >> >> anders@ubuntu:~/c$
> >> >>
> >> >>
> >> >>
> >> >> On Fri, May 6, 2011 at 8:58 PM, sourabh jakhar
> >> >> 
> >> >> wrote:
> >> >> >
> >> >> >
> >> >> > On Fri, May 6, 2011 at 4:23 PM, sourabh jakhar
> >> >> > 
> >> >> > wrote:
> >> >> >>
> >> >> >> You are given a large string. You need to cut the string into
> chunks
> >> >> >> such
> >> >> >> that each substring that you get is a palindrome. Remember that
> each
> >> >> >> 1
> >> >> >> length string is always a palindrome. You need to find the minimum
> >> >> >> number of
> >> >> >> cuts that you need to make such that each substring is a
> palindrome.
> >> >> >>
> >> >> >> --
> >> >> >> SOURABH JAKHAR,(CSE)(3 year)
> >> >> >> ROOM NO 167 ,
> >> >> >> TILAK,HOSTEL
> >> >> >> 'MNNIT ALLAHABAD
> >> >> >>
> >> >> >> The Law of Win says, "Let's not do it your way or my way; let's do
> >> >> >> it
> >> >> >> the
> >> >> >> best way."
> >> >> >>
> >> >> >> --
> >> >> >> You received this message because you are subscribed to the Google
> >> >> >> Gr

[algogeeks] Re: Test Cases

2011-05-10 Thread Don
I would add that you should test all combinations of positive and
negative operands.
You are not clear about the type being divided.
If it is a floating point type, you can verify that (a*b) / b = a to
an acceptable tolerance for a wide variety of values of a and b.
If you are working with integers, the case 4 below is good, given r <
b.
Don

On May 10, 11:12 am, Praveen Kumar  wrote:
> cases would be:
> 1. division by 0 raises an appropriate Exception
> 2. dividing 0 by any number should result in 0
> 3. dividing any number by 1 should give the same number
> 4. a = b*q + r i.e a/b should give q
>
> On Tue, May 10, 2011 at 7:52 PM, Carl Barton 
> wrote:
>
> > Don't really get the question
>
> > On 10 May 2011 09:08, Akshata Sharma  wrote:
>
> >> write test cases for the division '/' operator..
>
> >> --
> >> 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.



[algogeeks] Urgent need a Sr. ABAP Developer//Fremont, CA//4 Months Contract

2011-05-10 Thread peter req
*Urgent need a Sr. ABAP Developer*

*Please send updated Resume at **peter@gmail.com *

 *Start date: 05/23/2011*

*Duration: 4 Months Contract*

*Location: Fremont, CA*

*Rate: Open*

*Job Role & Skill set:* Application Developer - SAP.ABAP

*Service: SAP*

*Requested service/service area: SAP-Technical Infrastructure & Development
S8*

*Required skills: *Object oriented ABAP expertise with 8+yrs of experience
in ABAP.* *

*Pay travel and lodging: Yes*

*Thanks and Regards..*
**
*Peter*

-- 
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] Test Cases

2011-05-10 Thread Praveen Kumar
cases would be:
1. division by 0 raises an appropriate Exception
2. dividing 0 by any number should result in 0
3. dividing any number by 1 should give the same number
4. a = b*q + r i.e a/b should give q

On Tue, May 10, 2011 at 7:52 PM, Carl Barton wrote:

> Don't really get the question
>
>
> On 10 May 2011 09:08, Akshata Sharma  wrote:
>
>> write test cases for the division '/' operator..
>>
>> --
>> 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.



Re: [algogeeks] Test Cases

2011-05-10 Thread Carl Barton
Don't really get the question

On 10 May 2011 09:08, Akshata Sharma  wrote:

> write test cases for the division '/' operator..
>
> --
> 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.



Re: [algogeeks] [brain teaser] MATHS TRICK TEASER 9 may

2011-05-10 Thread saurabh singh
superlyk utkarsh solution..

On Tue, May 10, 2011 at 7:15 PM, UTKARSH SRIVASTAV
wrote:

> 19=10011
> 20=10100
> therefore take leftmost one from 19 and shift second one left and
> make it 10100=20
>
>
> On Tue, May 10, 2011 at 12:15 AM, Vandana Bachani 
> wrote:
>
>> 1 from 19 makes 20
>> 11 + 9 = 20 (take the one away from 19 and attach it to the other one and
>> put a + between the 2)
>>
>> -Vandana
>>
>>
>> On Tue, May 10, 2011 at 12:39 PM, Lavesh Rawat wrote:
>>
>>> *MATHS TRICK TEASER
>>> * * ***
>>> *
>>> *
>>> **
>>> *Prove that taking away 1 from 19 makes 20.
>>> *
>>>
>>> *Update Your Answers at* : Click 
>>> Here
>>>
>>>
>>> Solution:
>>> Will be updated after 1 day
>>>
>>>
>>>
>>>
>>> --
>>>
>>> "Never explain yourself. Your friends don’t need it
>>> and your enemies won’t believe it" .
>>>
>>> --
>>> 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.
>>
>
>
>
> --
> *UTKARSH SRIVASTAV
> CSE-3
> B-Tech 2nd Year
> @MNNIT 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.
>



-- 
Saurabh Singh
B.Tech (Computer Science)
MNNIT 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.



Re: [algogeeks] [brain teaser] MATHS TRICK TEASER 9 may

2011-05-10 Thread UTKARSH SRIVASTAV
19=10011
20=10100
therefore take leftmost one from 19 and shift second one left and
make it 10100=20

On Tue, May 10, 2011 at 12:15 AM, Vandana Bachani wrote:

> 1 from 19 makes 20
> 11 + 9 = 20 (take the one away from 19 and attach it to the other one and
> put a + between the 2)
>
> -Vandana
>
>
> On Tue, May 10, 2011 at 12:39 PM, Lavesh Rawat wrote:
>
>> *MATHS TRICK TEASER
>>  *
>> *
>> *
>> **
>> *Prove that taking away 1 from 19 makes 20.
>> *
>>
>> *Update Your Answers at* : Click 
>> Here
>>
>>
>> Solution:
>> Will be updated after 1 day
>>
>>
>>
>>
>> --
>>
>> "Never explain yourself. Your friends don’t need it
>> and your enemies won’t believe it" .
>>
>> --
>> 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.
>



-- 
*UTKARSH SRIVASTAV
CSE-3
B-Tech 2nd Year
@MNNIT 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.



[algogeeks] Test Cases

2011-05-10 Thread Akshata Sharma
write test cases for the division '/' operator..

-- 
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] [brain teaser] MATHS TRICK TEASER 9 may

2011-05-10 Thread Vandana Bachani
1 from 19 makes 20
11 + 9 = 20 (take the one away from 19 and attach it to the other one and
put a + between the 2)

-Vandana

On Tue, May 10, 2011 at 12:39 PM, Lavesh Rawat wrote:

> *MATHS TRICK TEASER
>  *
> *
> *
> **
> *Prove that taking away 1 from 19 makes 20.
> *
>
> *Update Your Answers at* : Click 
> Here
>
>
> Solution:
> Will be updated after 1 day
>
>
>
>
> --
>
> "Never explain yourself. Your friends don’t need it and
> your enemies won’t believe it" .
>
> --
> 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.



[algogeeks] Regarding the Master's project

2011-05-10 Thread Sweety
Hi All,
I am student at CSUS. I am looking some topics on database or cloud
computing for my Master's project.

It would be helpful, if anyone provides me an good idea on it.

Thanks,
Sweety

-- 
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] [brain teaser] MATHS TRICK TEASER 9 may

2011-05-10 Thread Lavesh Rawat
*MATHS TRICK TEASER
 *
*
*
**
*Prove that taking away 1 from 19 makes 20.
*

*Update Your Answers at* : Click
Here


Solution:
Will be updated after 1 day




-- 

"Never explain yourself. Your friends don’t need it and
your enemies won’t believe it" .

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