Re: [algogeeks] Unique characters in a string

2011-07-22 Thread rajeev bharshetty
@Victor : Counting sort uses extra data structures to maintain the count and
the output array , so it is not viable I think ?? what say ??

On Sat, Jul 23, 2011 at 11:04 AM, Victor Manuel Grijalva Altamirano <
kavic1.mar...@gmail.com> wrote:

> Use a type of counting sort with ascii
>
>
> 2011/7/22 SkRiPt KiDdIe 
>
>> Use 8 mask integers or 4 LL to cover the complete ascii range.
>>
>> --
>> 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.
>>
>
>
>
> --
> Victor Manuel Grijalva Altamirano
> Universidad Tecnologica de La Mixteca
>
>  --
> 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
Rajeev N B 

-- 
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] Sorting in O(n)

2011-07-22 Thread rajeev bharshetty
Given a valid range sort keys, the linked list can be sorted in O9n) time
using counting sort which takes O(n+k) comparisons to sort the list of K
elements .

On Sat, Jul 23, 2011 at 9:58 AM, Ankur Khurana wrote:

> 10^9->-10^9 -> 8-> 7- > NULL . It wont help in this case...
>
>
> On Sat, Jul 23, 2011 at 9:55 AM, keyan karthi 
> wrote:
>
>> counting sort ll help to some extent... find the min and max element O(n)
>> now u just need an array of size  "max-min" to store the values then
>> just traverse the list and while updating u do value+min... still it is not
>> suitable if the magnitude is high.
>>
>>
>> On Sat, Jul 23, 2011 at 9:45 AM, Ankur Khurana 
>> wrote:
>>
>>> n logn merge sort.count sort only when range is
>>> known.
>>>
>>>
>>> On Sat, Jul 23, 2011 at 1:35 AM, sunny agrawal 
>>> wrote:
>>>
 Cannot be done in O(N) if elements of list can take any value because
 then counting sort wont help

 On Sat, Jul 23, 2011 at 1:24 AM, Pankaj wrote:

> For linklist? How
>
>
> On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal <
> kamakshi...@gmail.com> wrote:
>
>> use counting sort..
>>
>>
>> On Sat, Jul 23, 2011 at 1:22 AM, rShetty wrote:
>>
>>> How to sort Linked lists in O(n) time ??
>>> Give the algorithm or the explanation or clue to tackle the problem
>>>
>>> --
>>> 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,
>> Kamakshi
>> kamakshi...@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.
>>
>
>  --
> 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.
>



 --
 Sunny Aggrawal
 B-Tech IV year,CSI
 Indian Institute Of Technology,Roorkee

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

>>>
>>>
>>>
>>> --
>>> Ankur Khurana
>>> Computer Science
>>> Netaji Subhas Institute Of Technology
>>> 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.
>>>
>>
>>  --
>> 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.
>>
>
>
>
> --
> Ankur Khurana
> Computer Science
> Netaji Subhas Institute Of Technology
> 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.
>



-- 
Regards
Rajeev N B 

-- 
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] chronus corp..

2011-07-22 Thread sush57
can anyone suggest interview questions for chronus corp...i have
interview on august 1st...

-- 
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] explain plzz:output in file old.out

2011-07-22 Thread shady
ya, you are right, but it returns -1 when it reaches the end of file.

On Sat, Jul 23, 2011 at 9:15 AM, arun kumar  wrote:

> @shady:i have a doubt. scanf returns number of succesfully read words.
> how come it will return -1?
>
> On Sat, Jul 23, 2011 at 12:17 AM, geek forgeek 
> wrote:
> > @shady and @varun ...
> > i hav got it
> > thanx both of u  :)
> >
> > On Fri, Jul 22, 2011 at 11:31 AM, shady  wrote:
> >>
> >> @aditi the problem is scanf returns -1(EOF value) when it encounters the
> >> end of file, and inspite of comparing the return value of scanf he is
> >> comparing value of character 'a' which is not correct
> >> therefore the for loop should be like this :
> >> for(int t=scanf("%c",&a);t!=EOF;t=scanf("%c",&a))
> >> what varun suggested is another way of doing it :)
> >>
> >> On Fri, Jul 22, 2011 at 11:41 PM, aditi garg  >
> >> wrote:
> >>>
> >>> @shady. so in this case we shud use a!=-1 as the condition??
> >>>
> >>> On Fri, Jul 22, 2011 at 11:37 PM, shady  wrote:
> 
>  you are scanning from stdin therefore it is not coming out of first
> for
>  loop... because your terminating condition is for EOF, which is -1(
> scanf
>  returns -1 ) at the end.
> 
>  On Fri, Jul 22, 2011 at 11:34 PM, shady  wrote:
> >
> > well you didn't mention the question, directly posted the code with
> no
> > head-tail... wait will answer, it is not coming out of first loop
> >
> > On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek <
> geekhori...@gmail.com>
> > wrote:
> >>
> >> @shady this is nt a joke..
> >> sorry if i am asking too stupid question
> >> i m getting an infinite loop here.
> >> not getting how?
> >>
> >> On Fri, Jul 22, 2011 at 10:40 AM, shady  wrote:
> >>>
> >>> what kind of joke is this ?
> >>>
> >>> On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek
> >>>  wrote:
> 
>  #include
>  main()
>  {
>  FILE *fp;
>  char a;
>  fp=fopen("old.out","w");
>  if(fp==0)
>  printf("File opening error");
>  else
>  {
>  for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
>  fprintf(fp,"%c",a);
>  fclose(fp);
>  fp=fopen("old.out","r");
>  while(!feof(fp))
>  putchar(getc(fp));
>  }
>  }
> 
>  --
>  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.
> >
> 
>  --
>  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.
> >>>
> >>>
> >>>
> >>> --
> >>> Aditi Garg
> >>> Undergraduate Student
> >>> Electronics & Communication Divison
> >>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
> >>> Sector 3, Dwarka
> >>> New Delhi
> >>> 9718388816
> >>>
> >>> --
> >>> 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 grou

[algogeeks] Re: Coding..........

2011-07-22 Thread яαωαт Jee
@ popli:  plz change ur email id..placement session will start soon.

On Jul 22, 8:32 pm, Gaurav Popli  wrote:
> an O(n) soln
> traveres the array...as you receive odd number put that index in
> queuewhen received an even numb check if queue is empty or
> not...if queue is empty the do nothing else swap with the head of the
> queue
>
> hope it worksit also maintains the stability of aarray...
>
>
>
>
>
>
>
> On Fri, Jul 22, 2011 at 6:39 PM, Kunal Patil  wrote:
> > @Sunny: Excellent explanation (& solution) !!
>
> > --
> > 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] Unique characters in a string

2011-07-22 Thread Victor Manuel Grijalva Altamirano
Use a type of counting sort with ascii

2011/7/22 SkRiPt KiDdIe 

> Use 8 mask integers or 4 LL to cover the complete ascii range.
>
> --
> 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.
>



-- 
Victor Manuel Grijalva Altamirano
Universidad Tecnologica de La Mixteca

-- 
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] Unique characters in a string

2011-07-22 Thread SkRiPt KiDdIe
Use 8 mask integers or 4 LL to cover the complete ascii range.

-- 
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] Unique characters in a string

2011-07-22 Thread rajeev bharshetty
Use Quick sort to sort the characters of a string (qsort is inplace sorting
) then check for consecutive characters in the array,  if they are same then
the string is not unique else unique .(use builtin qsort in C .) No
additional data structure is used ... What do u think of this guys ??

On Sat, Jul 23, 2011 at 9:52 AM, Reynald  wrote:

> Implement an algorithm to determine if a string has all unique
> characters. What if you can not use additional data structures?
>
> --
> 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
Rajeev N B 

-- 
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] Unique characters in a string

2011-07-22 Thread Ankur Khurana
what if cahrs are in ascii code range and not just characters. Any solution
for that ?

On Sat, Jul 23, 2011 at 9:57 AM, keyan karthi wrote:

> u can use an integer as a "bit mask" to do this... by setting the
>  -'a' th bit, and checking the same..
>
>
> On Sat, Jul 23, 2011 at 9:52 AM, Reynald  wrote:
>
>> Implement an algorithm to determine if a string has all unique
>> characters. What if you can not use additional data structures?
>>
>> --
>> 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.
>



-- 
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
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] Sorting in O(n)

2011-07-22 Thread Ankur Khurana
10^9->-10^9 -> 8-> 7- > NULL . It wont help in this case...

On Sat, Jul 23, 2011 at 9:55 AM, keyan karthi wrote:

> counting sort ll help to some extent... find the min and max element O(n)
> now u just need an array of size  "max-min" to store the values then
> just traverse the list and while updating u do value+min... still it is not
> suitable if the magnitude is high.
>
>
> On Sat, Jul 23, 2011 at 9:45 AM, Ankur Khurana 
> wrote:
>
>> n logn merge sort.count sort only when range is known.
>>
>>
>> On Sat, Jul 23, 2011 at 1:35 AM, sunny agrawal 
>> wrote:
>>
>>> Cannot be done in O(N) if elements of list can take any value because
>>> then counting sort wont help
>>>
>>> On Sat, Jul 23, 2011 at 1:24 AM, Pankaj wrote:
>>>
 For linklist? How


 On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal <
 kamakshi...@gmail.com> wrote:

> use counting sort..
>
>
> On Sat, Jul 23, 2011 at 1:22 AM, rShetty  wrote:
>
>> How to sort Linked lists in O(n) time ??
>> Give the algorithm or the explanation or clue to tackle the problem
>>
>> --
>> 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,
> Kamakshi
> kamakshi...@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.
>

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

>>>
>>>
>>>
>>> --
>>> Sunny Aggrawal
>>> B-Tech IV year,CSI
>>> Indian Institute Of Technology,Roorkee
>>>
>>>  --
>>> 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.
>>>
>>
>>
>>
>> --
>> Ankur Khurana
>> Computer Science
>> Netaji Subhas Institute Of Technology
>> 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.
>>
>
>  --
> 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.
>



-- 
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
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] Unique characters in a string

2011-07-22 Thread keyan karthi
u can use an integer as a "bit mask" to do this... by setting the
 -'a' th bit, and checking the same..

On Sat, Jul 23, 2011 at 9:52 AM, Reynald  wrote:

> Implement an algorithm to determine if a string has all unique
> characters. What if you can not use additional data structures?
>
> --
> 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] Sorting in O(n)

2011-07-22 Thread keyan karthi
counting sort ll help to some extent... find the min and max element O(n)
now u just need an array of size  "max-min" to store the values then
just traverse the list and while updating u do value+min... still it is not
suitable if the magnitude is high.

On Sat, Jul 23, 2011 at 9:45 AM, Ankur Khurana wrote:

> n logn merge sort.count sort only when range is known.
>
>
> On Sat, Jul 23, 2011 at 1:35 AM, sunny agrawal wrote:
>
>> Cannot be done in O(N) if elements of list can take any value because then
>> counting sort wont help
>>
>> On Sat, Jul 23, 2011 at 1:24 AM, Pankaj wrote:
>>
>>> For linklist? How
>>>
>>>
>>> On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal <
>>> kamakshi...@gmail.com> wrote:
>>>
 use counting sort..


 On Sat, Jul 23, 2011 at 1:22 AM, rShetty  wrote:

> How to sort Linked lists in O(n) time ??
> Give the algorithm or the explanation or clue to tackle the problem
>
> --
> 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,
 Kamakshi
 kamakshi...@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.

>>>
>>>  --
>>> 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.
>>>
>>
>>
>>
>> --
>> Sunny Aggrawal
>> B-Tech IV year,CSI
>> Indian Institute Of Technology,Roorkee
>>
>>  --
>> 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.
>>
>
>
>
> --
> Ankur Khurana
> Computer Science
> Netaji Subhas Institute Of Technology
> 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.
>

-- 
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] Unique characters in a string

2011-07-22 Thread Reynald
Implement an algorithm to determine if a string has all unique
characters. What if you can not use additional data structures?

-- 
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] Sorting in O(n)

2011-07-22 Thread Ankur Khurana
n logn merge sort.count sort only when range is known.

On Sat, Jul 23, 2011 at 1:35 AM, sunny agrawal wrote:

> Cannot be done in O(N) if elements of list can take any value because then
> counting sort wont help
>
> On Sat, Jul 23, 2011 at 1:24 AM, Pankaj  wrote:
>
>> For linklist? How
>>
>>
>> On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal <
>> kamakshi...@gmail.com> wrote:
>>
>>> use counting sort..
>>>
>>>
>>> On Sat, Jul 23, 2011 at 1:22 AM, rShetty  wrote:
>>>
 How to sort Linked lists in O(n) time ??
 Give the algorithm or the explanation or clue to tackle the problem

 --
 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,
>>> Kamakshi
>>> kamakshi...@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.
>>>
>>
>>  --
>> 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.
>>
>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
>  --
> 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.
>



-- 
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
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] explain plzz:output in file old.out

2011-07-22 Thread arun kumar
@shady:i have a doubt. scanf returns number of succesfully read words.
how come it will return -1?

On Sat, Jul 23, 2011 at 12:17 AM, geek forgeek  wrote:
> @shady and @varun ...
> i hav got it
> thanx both of u  :)
>
> On Fri, Jul 22, 2011 at 11:31 AM, shady  wrote:
>>
>> @aditi the problem is scanf returns -1(EOF value) when it encounters the
>> end of file, and inspite of comparing the return value of scanf he is
>> comparing value of character 'a' which is not correct
>> therefore the for loop should be like this :
>> for(int t=scanf("%c",&a);t!=EOF;t=scanf("%c",&a))
>> what varun suggested is another way of doing it :)
>>
>> On Fri, Jul 22, 2011 at 11:41 PM, aditi garg 
>> wrote:
>>>
>>> @shady. so in this case we shud use a!=-1 as the condition??
>>>
>>> On Fri, Jul 22, 2011 at 11:37 PM, shady  wrote:

 you are scanning from stdin therefore it is not coming out of first for
 loop... because your terminating condition is for EOF, which is -1( scanf
 returns -1 ) at the end.

 On Fri, Jul 22, 2011 at 11:34 PM, shady  wrote:
>
> well you didn't mention the question, directly posted the code with no
> head-tail... wait will answer, it is not coming out of first loop
>
> On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek 
> wrote:
>>
>> @shady this is nt a joke..
>> sorry if i am asking too stupid question
>> i m getting an infinite loop here.
>> not getting how?
>>
>> On Fri, Jul 22, 2011 at 10:40 AM, shady  wrote:
>>>
>>> what kind of joke is this ?
>>>
>>> On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek
>>>  wrote:

 #include
 main()
 {
     FILE *fp;
     char a;
     fp=fopen("old.out","w");
     if(fp==0)
         printf("File opening error");
     else
     {
         for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
         fprintf(fp,"%c",a);
         fclose(fp);
         fp=fopen("old.out","r");
         while(!feof(fp))
             putchar(getc(fp));
         }
 }

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

 --
 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.
>>>
>>>
>>>
>>> --
>>> Aditi Garg
>>> Undergraduate Student
>>> Electronics & Communication Divison
>>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
>>> Sector 3, Dwarka
>>> New Delhi
>>> 9718388816
>>>
>>> --
>>> 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.
> 

Re: [algogeeks] Re: MICROSOFT!!!!

2011-07-22 Thread naveen ms
one can use recursion for this

int gcd(int u,int v)
{
if(u==0) return v;
else if(v==0) return u;
else if(u%2==0&&v%2==0) return 2*gcd(u/2,v/2);
else if(u%2==0&&v%2!=0) return gcd(u/2,v);
else if(v%2==0&&u%2!=0) return gcd(u,v/2);
else if(u>v) return gcd((u-v)/2),v);
else if(u<=v)
   return gcd(u,(v-u)/2);

with regards
naveen

-- 
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: Coding Ques..............

2011-07-22 Thread Rajeev Kumar
check
http://tech-queries.blogspot.com/2009/05/max-possible-sum-of-non-consecutive.html

On Wed, Jul 20, 2011 at 11:58 PM, sunny agrawal wrote:

> Just take an extra array that will keep track of the values from which we
> get the best in solution to that thread.
>
>
>
> On Thu, Jul 21, 2011 at 8:55 AM, UMESH KUMAR wrote:
>
>> Hi
>> @Somnath my question is some different
>>
>> if given array :3,2,7,10
>> So according to last discussion Only Out put is *13 *not the show
>> elements
>> Output :: {3,10}
>>
>> So basically my question is that how to pick all elements that return max
>> sum
>>
>> Thanks..
>>
>>  --
>> 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.
>>
>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
>
>  --
> 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.
>



-- 
Thank You
Rajeev 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.



Re: [algogeeks] Add Two Numbers stored in Linked Lists

2011-07-22 Thread Rajeev Kumar
Please check this program in java and add your comments if you feel anything
wrong
http://rajeevprasanna.blogspot.com/2011/07/add-two-numbers-stored-in-linked-lists.html

2011/7/18 η!Ƭ!گђ 

> #include 
> #include 
> #include 
>
> struct node
> {
> char ch;
>  struct node *ptr;
> }*tp,*sp;
>
> int c = 0;
> int insert(struct node *list)
> {
> int n,num,hd;
>  scanf("%d",&n);
> hd = n;
> struct node *temp;
>  n--;
> while(n--)
> {
> scanf("%d",&num);
>  list->ch = num;
> temp = (struct node *)malloc(sizeof(struct node));
> list->ptr = temp;
>  list = list->ptr;
> }
> scanf("%d",&num);
>  list->ch = num;
> return hd;
> }
>
> void add(struct node *list1,struct node *list2)
> {
> if((list1 && list1->ptr) && (list2 && list2->ptr))
> add(list1->ptr,list2->ptr);
>  struct node *temp;
> temp = (struct node *)malloc(sizeof(struct node));
> if((c + (list1->ch + list2->ch)) >= 10){
>  tp->ch = (c + (list1->ch+list2->ch)) -10;
> c = 1;
> tp ->ptr = temp;
>  tp = tp->ptr;
> }
> else{
>  tp->ch = (c + list1->ch + list2->ch);
> c = 0;
> tp->ptr = temp;
>  tp = tp->ptr;
> }
> }
>
> void print(struct node *list)
> {
> if(list->ptr)
> {
> print(list->ptr);
>  printf("%d ",list->ch);
> }
> else if(list->ch)
>  printf("%d ",list->ch);
> }
>
> int main()
> {
> int pos1,pos2,x;
>  struct node *list1,*list2,*temp;
> list1 = (struct node *)malloc(sizeof(struct node));
>  list2 = (struct node *)malloc(sizeof(struct node));
> temp = (struct node *)malloc (sizeof(struct node));
>  sp = (struct node *)malloc(sizeof(struct node));
> sp = temp;
> pos1 = insert(list1);
>  pos2 = insert(list2);
> if(pos1>pos2)
> x = pos1-pos2-1;
>  else
> x = pos2-pos1-1;
>
> while((x--) > 0){
>  temp->ch = 0;
> tp = (struct node *)malloc(sizeof(struct node));
> temp->ptr = tp;
>  temp = temp->ptr;
> }
> if(pos2 > pos1){
>  temp->ch = 0;
> temp->ptr = list1;
> list1 = sp;
>  }
> else if(pos1 > pos2){
> temp->ch =0;
>  temp->ptr = list2;
> list2 = sp;
> }
>  tp = (struct node *)malloc(sizeof(struct node));
> sp = tp;
> add(list1,list2);
>  tp->ch = c;
> print(sp);
> printf("\n");
>  return 0;
> }
>
>
> On Tue, Jul 19, 2011 at 1:10 AM, SkRiPt KiDdIe wrote:
>
>> #include
>> #include
>> using namespace std;
>>
>> struct node{
>> int val;
>> node *next;
>> };
>>
>> node * Input(int n)
>> {
>> node *temp,*list,*end;
>>
>> int x;
>> for(int i=0;i> {
>> cin>>x;
>>
>> temp=(node*)malloc(sizeof(node));temp->val=x;temp->next=NULL;
>>
>> if(!i)list=end=temp;
>> else end=end->next=temp;
>> }
>> return list;
>> }
>> void Rev(node *&head,node *add)
>> {
>> if(!head){head=add;return;}
>> node *t=head;head=head->next;
>> Rev(head,t);
>> t->next=add;
>> }
>> void Show(node *head)
>> {
>> while(head){coutnext;}
>> cout<<"\n\n";
>> }
>> node * Add(node* a, node *b,node *c,int carry)
>> {
>> node *temp;
>>
>> if(!a)
>> {
>> while(carry)
>> {
>> temp=(node*)malloc(sizeof(node));
>> temp->val=carry%10;temp->next=NULL;
>> carry/=10;
>> c=c->next=temp;
>> }return c;
>> }
>>
>> temp=(node*)malloc(sizeof(node));
>> temp->val=(a->val+b->val+carry)%10;
>>
>> if(!c)c=temp;
>> else c=c->next=temp;
>>
>> Add(a->next,b->next,c,(a->val+b->val+carry)/10);
>> return c;
>> }
>> int main()
>> {
>>
>> node *list1,*list2,*list3=NULL,*temp;
>>
>> int n1,n2;
>>
>> cin>>n1;
>> list1=Input(n1);//Input list 1
>> cin>>n2;
>> list2=Input(n2);//Input list 2
>>
>>
>> if(n2>n1)while((n2--)-n1){temp=(node*)malloc(sizeof(node));temp->val=0;temp->next=list1;list1=temp;}
>> else
>> while((n1--)-n2){temp=(node*)malloc(sizeof(node));temp->val=0;temp->next=list2;list2=temp;}
>>
>>
>> Rev(list1,NULL);
>> Rev(list2,NULL);
>> list3=Add(list1,list2,list3,0);
>> Rev(list3,NULL);
>> Show(list3);
>> 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.
>>
>
>  --
> 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.
>



-- 
Thank You
Rajeev 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 
a

Re: [algogeeks] Array traversal with rules..

2011-07-22 Thread Yuchen Liao
Yes, this is a simple DP problem:

#include 
#include 

#define MAX 10

int main()
{
int n, a[100], dp[100];
while(scanf("%d", &n) == 1)
{
for(int i = 0; i < n; i++){
scanf("%d", &a[i]);
dp[i] = MAX;
}

dp[n - 1] = 0;
for(int i = n - 2; i > -1; i--)
for(int j = i + 1; j < n && j - i <= a[i]; j++)
if(dp[i] > dp[j] + 1) dp[i] = dp[j] + 1;

if(dp[0] < MAX) printf("%d\n", dp[0]);
else printf("Never!\n");

}
return 0;
}


On Fri, Jul 22, 2011 at 5:25 PM, sukhmeet singh wrote:

> You are given an array with some values..traverse the array according to
> the rule that if a[i]=x then you can jump max up to x steps.. (if a[i]=0
> then you can't move any forward)
> find the least number of steps required to traverse the array ...
>
> EG:a[]=1 3 5 8 9 7 8 0 2 this requires 3 steps to traverse the array ..
> I think its DP .. but its just my intuition ..!!
>
>  --
> 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.
>



-- 
from Yuchen Liao via Gmail
yyloves.me

-- 
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] Array traversal with rules..

2011-07-22 Thread sukhmeet singh
You are given an array with some values..traverse the array according to the
rule that if a[i]=x then you can jump max up to x steps.. (if a[i]=0 then
you can't move any forward)
find the least number of steps required to traverse the array ...

EG:a[]=1 3 5 8 9 7 8 0 2 this requires 3 steps to traverse the array ..
I think its DP .. but its just my intuition ..!!

-- 
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: MICROSOFT!!!!

2011-07-22 Thread sukhmeet singh
what DS u used in the 3rd question ??

On Fri, Jul 22, 2011 at 8:22 PM, siva viknesh wrote:

> @ankur.. as u said i m posting today :) :)
>
> 10 questions c output, one compiler based(CFG) ,one OS
> based (when reading internally it was just a simple percentage
> calculation question)..
>
> +3 for correct ans..
> -2 for wrong ans...Damn it.. i dint notice d negative marking and
> attended all :(
>
> ...questions were not so tough (neither so easy :P) and all , u just
> need to think aloud
>
> 10 marks :
>
> 1. Find gcd of 2 numbers U & V in O(log UV)^2
>
> 2.   Test cases for finger print recognition say in a laptop to login
>
> 3. Design question..for billing , u have barcode, barcode number,
> item price, taxes, discounts for items (some criteria were given and u
> have to  design an algo for calculating discount) and then finally
> compute Net pricewhat DS u ll usehow ll u improve this
> design...State advantages and disadvantages.
>
> u have to think aloud and innovative ..thats it :)
>
> On Jul 18, 8:46 pm, Ankur Garg  wrote:
> > post on 22nd itself bro ;) ..there is a written  test on 23rd
> >
> > On Mon, Jul 18, 2011 at 8:45 PM, siva viknesh  >wrote:
> >
> >
> >
> >
> >
> >
> >
> > > @all..thanks a lotsure ll post the questions after 22nd :)
> >
> > > On Jul 18, 8:13 pm, sourabh jakhar  wrote:
> > > > study basic well they give a lot of emphasis on them
> >
> > > > On Mon, Jul 18, 2011 at 8:41 PM, SkRiPt KiDdIe <
> anuragmsi...@gmail.com
> > > >wrote:
> >
> > > > > After 22nd plz post ur questions ... !!
> > > > > It wud be of great HelP.
> >
> > > > > --
> > > > > 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.
> >
> > > > --
> > > > SOURABH JAKHAR,(CSE)(Final 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
> 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] Re: MICROSOFT!!!!

2011-07-22 Thread sukhmeet singh
Algo for gcd(u,v) :
gcd(0,v)=v and gcd(u,0)=u;
gcd(u,v)=2*(gcd(u/2,v/2)) if u and v are multiples of 2
gcd(u,v)=gcd(u/2 ,v) if u is a multiple of 2 and v is not
gcd(u,v)=gcd(u,v/2) if v is a multiple of 2 and u is not
gcd(u,v)= gcd((u-v)/2,v) if u and v are not multiples of 2 and u>=v
gcd(u,v)=gcd((v-u)/2,u) if u and v are not multiples of 2 and v>u

repeat above steps .. till found..
one thing more gcd(0,0) is not defined but can be assumed to be 0

On Fri, Jul 22, 2011 at 8:29 PM, shady  wrote:

> what was it ? job interview questions or intern ?
>
> gcd can always be found in O(log(larger number)) , sorry, couldnt
> understand the complexity in that ?
>
>
> On Fri, Jul 22, 2011 at 8:22 PM, siva viknesh wrote:
>
>> @ankur.. as u said i m posting today :) :)
>>
>> 10 questions c output, one compiler based(CFG) ,one OS
>> based (when reading internally it was just a simple percentage
>> calculation question)..
>>
>> +3 for correct ans..
>> -2 for wrong ans...Damn it.. i dint notice d negative marking and
>> attended all :(
>>
>> ...questions were not so tough (neither so easy :P) and all , u just
>> need to think aloud
>>
>> 10 marks :
>>
>> 1. Find gcd of 2 numbers U & V in O(log UV)^2
>>
>> 2.   Test cases for finger print recognition say in a laptop to login
>>
>> 3. Design question..for billing , u have barcode, barcode number,
>> item price, taxes, discounts for items (some criteria were given and u
>> have to  design an algo for calculating discount) and then finally
>> compute Net pricewhat DS u ll usehow ll u improve this
>> design...State advantages and disadvantages.
>>
>> u have to think aloud and innovative ..thats it :)
>>
>> On Jul 18, 8:46 pm, Ankur Garg  wrote:
>> > post on 22nd itself bro ;) ..there is a written  test on 23rd
>> >
>> > On Mon, Jul 18, 2011 at 8:45 PM, siva viknesh > >wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > @all..thanks a lotsure ll post the questions after 22nd :)
>> >
>> > > On Jul 18, 8:13 pm, sourabh jakhar  wrote:
>> > > > study basic well they give a lot of emphasis on them
>> >
>> > > > On Mon, Jul 18, 2011 at 8:41 PM, SkRiPt KiDdIe <
>> anuragmsi...@gmail.com
>> > > >wrote:
>> >
>> > > > > After 22nd plz post ur questions ... !!
>> > > > > It wud be of great HelP.
>> >
>> > > > > --
>> > > > > 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.
>> >
>> > > > --
>> > > > SOURABH JAKHAR,(CSE)(Final 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
>> 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.
>

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

2011-07-22 Thread Anurag Narain
O(n) solution:

odd_index=-1;
even_index=-1;

//now find first odd no.'s index
for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Sorting in O(n)

2011-07-22 Thread sunny agrawal
Cannot be done in O(N) if elements of list can take any value because then
counting sort wont help

On Sat, Jul 23, 2011 at 1:24 AM, Pankaj  wrote:

> For linklist? How
>
>
> On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal  > wrote:
>
>> use counting sort..
>>
>>
>> On Sat, Jul 23, 2011 at 1:22 AM, rShetty  wrote:
>>
>>> How to sort Linked lists in O(n) time ??
>>> Give the algorithm or the explanation or clue to tackle the problem
>>>
>>> --
>>> 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,
>> Kamakshi
>> kamakshi...@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.
>>
>
>  --
> 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.
>



-- 
Sunny Aggrawal
B-Tech IV year,CSI
Indian Institute Of Technology,Roorkee

-- 
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] Sorting in O(n)

2011-07-22 Thread kashish jain
actually its a work around...first traverse the list and store it in an
array..
sort the array in o(n)
then replace the content of the linked list using the values in the array


On Sat, Jul 23, 2011 at 1:24 AM, Pankaj  wrote:

> For linklist? How
>
>
> On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal  > wrote:
>
>> use counting sort..
>>
>>
>> On Sat, Jul 23, 2011 at 1:22 AM, rShetty  wrote:
>>
>>> How to sort Linked lists in O(n) time ??
>>> Give the algorithm or the explanation or clue to tackle the problem
>>>
>>> --
>>> 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,
>> Kamakshi
>> kamakshi...@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.
>>
>
>  --
> 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] Sorting in O(n)

2011-07-22 Thread Pankaj
For linklist? How

On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal
wrote:

> use counting sort..
>
>
> On Sat, Jul 23, 2011 at 1:22 AM, rShetty  wrote:
>
>> How to sort Linked lists in O(n) time ??
>> Give the algorithm or the explanation or clue to tackle the problem
>>
>> --
>> 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,
> Kamakshi
> kamakshi...@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.
>

-- 
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] Sorting in O(n)

2011-07-22 Thread Kamakshii Aggarwal
use counting sort..

On Sat, Jul 23, 2011 at 1:22 AM, rShetty  wrote:

> How to sort Linked lists in O(n) time ??
> Give the algorithm or the explanation or clue to tackle the problem
>
> --
> 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,
Kamakshi
kamakshi...@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] Sorting in O(n)

2011-07-22 Thread rShetty
How to sort Linked lists in O(n) time ??
Give the algorithm or the explanation or clue to tackle the problem

-- 
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: Circular list

2011-07-22 Thread Pankaj
That can never be done in constant time :).
If you can find one solution, then please let us know.

On Sat, Jul 23, 2011 at 1:13 AM, rShetty  wrote:

> SO what about If my Linked list is a sorted list and the new node I
> wanna insert must maintain that sorted nature , So can then be the
> insertion of a node be done in constant time without traversing the
> list ??
>
> On Jul 23, 12:26 am, Pankaj  wrote:
> > If you know circular list, what is avoiding you from maintaining a tail
> > pointer.
> > You just need to tweak insert and delete function a little bit for corner
> > cases.
> >
> >
> >
> >
> >
> >
> >
> > On Sat, Jul 23, 2011 at 12:50 AM, rShetty  wrote:
> > > Algorithm Please ... Thank You
> >
> > > On Jul 23, 12:17 am, vaibhav shukla  wrote:
> > > > maintain just a tail pointer
> >
> > > > On Sat, Jul 23, 2011 at 12:45 AM, rShetty 
> wrote:
> > > > > Come Up with an Algorithm to implement the insertion of a node in
> > > > > circular linked list without actually traversing the list ?
> >
> > > > > --
> > > > > 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.
> >
> > > > --
> > > >   best wishes!!
> > > > Vaibhav
> > > >   MCA
> >
> > > --
> > > 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] Re: Circular list

2011-07-22 Thread vaibhav shukla
i think for sorted order. u hv to traverse the list.it cant be in const time

On Sat, Jul 23, 2011 at 1:13 AM, rShetty  wrote:

> SO what about If my Linked list is a sorted list and the new node I
> wanna insert must maintain that sorted nature , So can then be the
> insertion of a node be done in constant time without traversing the
> list ??
>
> On Jul 23, 12:26 am, Pankaj  wrote:
> > If you know circular list, what is avoiding you from maintaining a tail
> > pointer.
> > You just need to tweak insert and delete function a little bit for corner
> > cases.
> >
> >
> >
> >
> >
> >
> >
> > On Sat, Jul 23, 2011 at 12:50 AM, rShetty  wrote:
> > > Algorithm Please ... Thank You
> >
> > > On Jul 23, 12:17 am, vaibhav shukla  wrote:
> > > > maintain just a tail pointer
> >
> > > > On Sat, Jul 23, 2011 at 12:45 AM, rShetty 
> wrote:
> > > > > Come Up with an Algorithm to implement the insertion of a node in
> > > > > circular linked list without actually traversing the list ?
> >
> > > > > --
> > > > > 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.
> >
> > > > --
> > > >   best wishes!!
> > > > Vaibhav
> > > >   MCA
> >
> > > --
> > > 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.
>
>


-- 
  best wishes!!
Vaibhav
  MCA

-- 
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: Circular list

2011-07-22 Thread rShetty
SO what about If my Linked list is a sorted list and the new node I
wanna insert must maintain that sorted nature , So can then be the
insertion of a node be done in constant time without traversing the
list ??

On Jul 23, 12:26 am, Pankaj  wrote:
> If you know circular list, what is avoiding you from maintaining a tail
> pointer.
> You just need to tweak insert and delete function a little bit for corner
> cases.
>
>
>
>
>
>
>
> On Sat, Jul 23, 2011 at 12:50 AM, rShetty  wrote:
> > Algorithm Please ... Thank You
>
> > On Jul 23, 12:17 am, vaibhav shukla  wrote:
> > > maintain just a tail pointer
>
> > > On Sat, Jul 23, 2011 at 12:45 AM, rShetty  wrote:
> > > > Come Up with an Algorithm to implement the insertion of a node in
> > > > circular linked list without actually traversing the list ?
>
> > > > --
> > > > 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.
>
> > > --
> > >   best wishes!!
> > >     Vaibhav
> > >       MCA
>
> > --
> > 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] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Gaurav Popli
oh sorry...i didnt see.yeah..you are rightthanks..

On Sat, Jul 23, 2011 at 1:06 AM, sunny agrawal  wrote:
> But that will save only 50% of the prisoners...as compare to 99.5% in
> that of even Odd case
> Read that post carefully
>
> On Sat, Jul 23, 2011 at 1:04 AM, Gaurav Popli  wrote:
>>
>> or we cud make more easy for prisoners...instead of counting whether
>> even or notthe person at the back can say the color of the hat
>> which the prisoner in the immediate front is wearing.
>> by this atleast 50% prisoners will be relaesed/.
>> it will all depend on thr cooperation ;)
>>
>> On Fri, Jul 22, 2011 at 11:25 PM, Vishal Jain  wrote:
>> > I think Aditi's solution is correct. I was doing the same thing using
>> > XOR
>> > function... So basically I was saying to use XOR and interviewer was
>> > asking
>> > for something better... I could not find this solution...
>> > Thanks Aditi.
>> > Thanks & Regards
>> > Vishal Jain
>> > MNo: +91-9540611889
>> > Tweet @jainvis
>> > Blog @ jainvish.blogspot.com
>> > Success taste better when target achieved is bigger.
>> >
>> > P We have a responsibility to the environment.
>> >
>> > Before printing this e-mail or any other document, let's ask ourselves
>> > whether we need a hard copy.
>> >
>> >
>> > On Fri, Jul 22, 2011 at 10:19 PM, aditi garg 
>> > wrote:
>> >>
>> >> I think this can be answered like dis...
>> >> let us say that the persons have decided amongst themselves that if the
>> >> the number of people wearing white in front of dem is even he wud say
>> >> white
>> >> and if odd he wud say black
>> >> Now suppose the 100th person counts the number of hats and finds it to
>> >> be
>> >> even... he wud say white...
>> >> now the 99th person will do the same...if he still finds the number to
>> >> be
>> >> even and since the 100th person sed white(i.e even) he would say
>> >> black...now
>> >> if the 100th person had sed black (ie odd white) and the count comes
>> >> out to
>> >> be even thus 99 wud be wearing a white hat...
>> >> Now that 98th person knows dat 99 had sed the correct hat and using the
>> >> same method can say the correct hat color...thus all can be saved
>> >> except the
>> >> 100th prisoner...
>> >> Also note dat the 100th prisoner also has a 50% chance to survive...
>> >> Hope dis helps :)
>> >>
>> >> On Fri, Jul 22, 2011 at 10:05 PM, Shubham Maheshwari
>> >>  wrote:
>> >>>
>> >>> could some1 plz post the xplainations ...
>> >>>
>> >>> On Fri, Jul 22, 2011 at 8:04 PM, Pankaj 
>> >>> wrote:
>> 
>>  Chetan,
>>  No. How could you relate this problem with that? Do you find
>>  something
>>  similar?
>>  ~
>>  Pankaj
>> 
>>  On Fri, Jul 22, 2011 at 8:01 PM, chetan kapoor
>>   wrote:
>> >
>> > josehus problem???
>> >
>> > On Fri, Jul 22, 2011 at 7:57 PM, Pankaj 
>> > wrote:
>> >>
>> >> Skipp Riddle,
>> >> Yes.
>> >> 100th prisoner will risk his life. Similar puzzle was discuss
>> >> recently. Does anyone remember the name or thread?
>> >>
>> >> ~
>> >> Pankaj
>> >>
>> >> On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe
>> >>  wrote:
>> >>>
>> >>> Worst case 99 get released.
>> >>> Is that correct..?
>> >>>
>> >>> --
>> >>> 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.
>> 
>>  --
>>  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 mess

Re: [algogeeks]

2011-07-22 Thread Rakib Ansary Saikot
Well a "double" pointer (A more accurate term is multidimensional pointer,
in this case a two dimensional pointer) is basically a pointer to an array
of pointers.

So, int **ptr basically says, ptr is a pointer to an array of pointers. And
you can allocate memory to each of these pointers individually. See the
image.

Heres something interesting.

int **ptr;
*ptr = new int*[3]; // ptr points to THREE << pointers to integers >>
ptr[0] = new int [10];
ptr[1] = new int[23];
ptr[2] = new int[12];




On Sat, Jul 23, 2011 at 1:29 AM, Kamakshii Aggarwal
wrote:

> @rakib:can u please explain ur answer
>
>
> On Sat, Jul 23, 2011 at 12:48 AM, Pankaj wrote:
>
>> https://ideone.com/tr3Q7
>>
>>
>> On Sat, Jul 23, 2011 at 12:42 AM, Pankaj wrote:
>>
>>> double **p= (double **) malloc(sizeof(double *));
>>>
>>>
>>> On Sat, Jul 23, 2011 at 12:40 AM, Bhavesh agrawal >> > wrote:
>>>
 double pointer mean like **p

 hoe to allocate memory for this

 --
 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,
> Kamakshi
> kamakshi...@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.
>

-- 
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: Circular list

2011-07-22 Thread rShetty
So we should maintain a tail pointer and add nodes next to the tail
pointer ??? Right ???

On Jul 23, 12:26 am, Pankaj  wrote:
> If you know circular list, what is avoiding you from maintaining a tail
> pointer.
> You just need to tweak insert and delete function a little bit for corner
> cases.
>
>
>
>
>
>
>
> On Sat, Jul 23, 2011 at 12:50 AM, rShetty  wrote:
> > Algorithm Please ... Thank You
>
> > On Jul 23, 12:17 am, vaibhav shukla  wrote:
> > > maintain just a tail pointer
>
> > > On Sat, Jul 23, 2011 at 12:45 AM, rShetty  wrote:
> > > > Come Up with an Algorithm to implement the insertion of a node in
> > > > circular linked list without actually traversing the list ?
>
> > > > --
> > > > 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.
>
> > > --
> > >   best wishes!!
> > >     Vaibhav
> > >       MCA
>
> > --
> > 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] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread sunny agrawal
But that will save only 50% of the prisoners...as compare to 99.5% in
that of even Odd case
Read that post carefully

On Sat, Jul 23, 2011 at 1:04 AM, Gaurav Popli  wrote:

> or we cud make more easy for prisoners...instead of counting whether
> even or notthe person at the back can say the color of the hat
> which the prisoner in the immediate front is wearing.
> by this atleast 50% prisoners will be relaesed/.
> it will all depend on thr cooperation ;)
>
> On Fri, Jul 22, 2011 at 11:25 PM, Vishal Jain  wrote:
> > I think Aditi's solution is correct. I was doing the same thing using XOR
> > function... So basically I was saying to use XOR and interviewer was
> asking
> > for something better... I could not find this solution...
> > Thanks Aditi.
> > Thanks & Regards
> > Vishal Jain
> > MNo: +91-9540611889
> > Tweet @jainvis
> > Blog @ jainvish.blogspot.com
> > Success taste better when target achieved is bigger.
> >
> > P We have a responsibility to the environment.
> >
> > Before printing this e-mail or any other document, let's ask ourselves
> > whether we need a hard copy.
> >
> >
> > On Fri, Jul 22, 2011 at 10:19 PM, aditi garg 
> > wrote:
> >>
> >> I think this can be answered like dis...
> >> let us say that the persons have decided amongst themselves that if the
> >> the number of people wearing white in front of dem is even he wud say
> white
> >> and if odd he wud say black
> >> Now suppose the 100th person counts the number of hats and finds it to
> be
> >> even... he wud say white...
> >> now the 99th person will do the same...if he still finds the number to
> be
> >> even and since the 100th person sed white(i.e even) he would say
> black...now
> >> if the 100th person had sed black (ie odd white) and the count comes out
> to
> >> be even thus 99 wud be wearing a white hat...
> >> Now that 98th person knows dat 99 had sed the correct hat and using the
> >> same method can say the correct hat color...thus all can be saved except
> the
> >> 100th prisoner...
> >> Also note dat the 100th prisoner also has a 50% chance to survive...
> >> Hope dis helps :)
> >>
> >> On Fri, Jul 22, 2011 at 10:05 PM, Shubham Maheshwari
> >>  wrote:
> >>>
> >>> could some1 plz post the xplainations ...
> >>>
> >>> On Fri, Jul 22, 2011 at 8:04 PM, Pankaj 
> >>> wrote:
> 
>  Chetan,
>  No. How could you relate this problem with that? Do you find something
>  similar?
>  ~
>  Pankaj
> 
>  On Fri, Jul 22, 2011 at 8:01 PM, chetan kapoor
>   wrote:
> >
> > josehus problem???
> >
> > On Fri, Jul 22, 2011 at 7:57 PM, Pankaj 
> > wrote:
> >>
> >> Skipp Riddle,
> >> Yes.
> >> 100th prisoner will risk his life. Similar puzzle was discuss
> >> recently. Does anyone remember the name or thread?
> >>
> >> ~
> >> Pankaj
> >>
> >> On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe
> >>  wrote:
> >>>
> >>> Worst case 99 get released.
> >>> Is that correct..?
> >>>
> >>> --
> >>> 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.
> 
>  --
>  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

Re: [algogeeks]

2011-07-22 Thread Pankaj
int **x;
x = new int*[n];
for (int i = 0; i < n; i++){
x[i] = new int[m];

This algorithm will create a m*n matrix.
x= new int*[n] is same as allocating array of n which will be of (Int *)
type. It will store the address of n arrays of m size.
x[i]= new int[m] here we are allocating an array of m int. And assigning the
address of each array to memory allocated above.

Please let me know if I am wrong.

On Sat, Jul 23, 2011 at 12:59 AM, Kamakshii Aggarwal
wrote:

> @rakib:can u please explain ur answer
>
>
> On Sat, Jul 23, 2011 at 12:48 AM, Pankaj wrote:
>
>> https://ideone.com/tr3Q7
>>
>>
>> On Sat, Jul 23, 2011 at 12:42 AM, Pankaj wrote:
>>
>>> double **p= (double **) malloc(sizeof(double *));
>>>
>>>
>>> On Sat, Jul 23, 2011 at 12:40 AM, Bhavesh agrawal >> > wrote:
>>>
 double pointer mean like **p

 hoe to allocate memory for this

 --
 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,
> Kamakshi
> kamakshi...@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.
>

-- 
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] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Gaurav Popli
or we cud make more easy for prisoners...instead of counting whether
even or notthe person at the back can say the color of the hat
which the prisoner in the immediate front is wearing.
by this atleast 50% prisoners will be relaesed/.
it will all depend on thr cooperation ;)

On Fri, Jul 22, 2011 at 11:25 PM, Vishal Jain  wrote:
> I think Aditi's solution is correct. I was doing the same thing using XOR
> function... So basically I was saying to use XOR and interviewer was asking
> for something better... I could not find this solution...
> Thanks Aditi.
> Thanks & Regards
> Vishal Jain
> MNo: +91-9540611889
> Tweet @jainvis
> Blog @ jainvish.blogspot.com
> Success taste better when target achieved is bigger.
>
> P We have a responsibility to the environment.
>
> Before printing this e-mail or any other document, let's ask ourselves
> whether we need a hard copy.
>
>
> On Fri, Jul 22, 2011 at 10:19 PM, aditi garg 
> wrote:
>>
>> I think this can be answered like dis...
>> let us say that the persons have decided amongst themselves that if the
>> the number of people wearing white in front of dem is even he wud say white
>> and if odd he wud say black
>> Now suppose the 100th person counts the number of hats and finds it to be
>> even... he wud say white...
>> now the 99th person will do the same...if he still finds the number to be
>> even and since the 100th person sed white(i.e even) he would say black...now
>> if the 100th person had sed black (ie odd white) and the count comes out to
>> be even thus 99 wud be wearing a white hat...
>> Now that 98th person knows dat 99 had sed the correct hat and using the
>> same method can say the correct hat color...thus all can be saved except the
>> 100th prisoner...
>> Also note dat the 100th prisoner also has a 50% chance to survive...
>> Hope dis helps :)
>>
>> On Fri, Jul 22, 2011 at 10:05 PM, Shubham Maheshwari
>>  wrote:
>>>
>>> could some1 plz post the xplainations ...
>>>
>>> On Fri, Jul 22, 2011 at 8:04 PM, Pankaj 
>>> wrote:

 Chetan,
 No. How could you relate this problem with that? Do you find something
 similar?
 ~
 Pankaj

 On Fri, Jul 22, 2011 at 8:01 PM, chetan kapoor
  wrote:
>
> josehus problem???
>
> On Fri, Jul 22, 2011 at 7:57 PM, Pankaj 
> wrote:
>>
>> Skipp Riddle,
>> Yes.
>> 100th prisoner will risk his life. Similar puzzle was discuss
>> recently. Does anyone remember the name or thread?
>>
>> ~
>> Pankaj
>>
>> On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe
>>  wrote:
>>>
>>> Worst case 99 get released.
>>> Is that correct..?
>>>
>>> --
>>> 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.

 --
 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.
>>
>>
>>
>> --
>> Aditi Garg
>> Undergraduate Student
>> Electronics & Communication Divison
>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
>> Sector 3, Dwarka
>> New Delhi
>> 9718388816
>>
>> --
>> 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 

Re: [algogeeks]

2011-07-22 Thread Kamakshii Aggarwal
@rakib:can u please explain ur answer

On Sat, Jul 23, 2011 at 12:48 AM, Pankaj  wrote:

> https://ideone.com/tr3Q7
>
>
> On Sat, Jul 23, 2011 at 12:42 AM, Pankaj wrote:
>
>> double **p= (double **) malloc(sizeof(double *));
>>
>>
>> On Sat, Jul 23, 2011 at 12:40 AM, Bhavesh agrawal 
>> wrote:
>>
>>> double pointer mean like **p
>>>
>>> hoe to allocate memory for this
>>>
>>> --
>>> 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,
Kamakshi
kamakshi...@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: Circular list

2011-07-22 Thread Pankaj
If you know circular list, what is avoiding you from maintaining a tail
pointer.
You just need to tweak insert and delete function a little bit for corner
cases.

On Sat, Jul 23, 2011 at 12:50 AM, rShetty  wrote:

> Algorithm Please ... Thank You
>
> On Jul 23, 12:17 am, vaibhav shukla  wrote:
> > maintain just a tail pointer
> >
> > On Sat, Jul 23, 2011 at 12:45 AM, rShetty  wrote:
> > > Come Up with an Algorithm to implement the insertion of a node in
> > > circular linked list without actually traversing the list ?
> >
> > > --
> > > 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.
> >
> > --
> >   best wishes!!
> > Vaibhav
> >   MCA
>
> --
> 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] xplain output

2011-07-22 Thread rajeev bharshetty
I think when the mismatch of the format specifier and the variable occurs ,
the compiler generates random  number output as, some garbage I suppose .

On Sat, Jul 23, 2011 at 12:30 AM, geek forgeek wrote:

> #include
> void main()
> {
> int x;
> float t;
> scanf("%f",&t);
> printf("%f\n",t);
> x=90;
> printf("%f\n",x);
> {
> x=1;
> printf("%f\n",x);
> {
> x=30;
> printf("%f\n",x);
> }
> printf("%f\n",x);
> }
> x==9;
> printf("%f\n",x);
> }
>
> input
> 1.1
>
> output
> 1.10
> 1.09
> 1.09
> 1.09
> 1.09
> 1.09
>
> --
> 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
Rajeev N B 

-- 
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: Circular list

2011-07-22 Thread rShetty
Algorithm Please ... Thank You

On Jul 23, 12:17 am, vaibhav shukla  wrote:
> maintain just a tail pointer
>
> On Sat, Jul 23, 2011 at 12:45 AM, rShetty  wrote:
> > Come Up with an Algorithm to implement the insertion of a node in
> > circular linked list without actually traversing the list ?
>
> > --
> > 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.
>
> --
>   best wishes!!
>     Vaibhav
>       MCA

-- 
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: C OUTPUT HELP

2011-07-22 Thread geek forgeek
@nicks -- ur code for 1st problem is giving me 1 not -1 on gcc..which
compiler are you using

On Fri, Jul 22, 2011 at 11:58 AM, sumit  wrote:

> +1 to t3rminal
>
>
> On Jun 12, 11:38 pm, T3rminal  wrote:
> > @all
> > Stop guessing and making your own standards. C standards haven't
> > defined anything (though in gcc arguments are processed from left to
> > right) about processing arguments in a function call. And sentence
> > like "assgnment to a preincrement expression is delayed vry mch"
> > have no meaning . Seriously which book have you referred.
> > This all fall in category of UNDEFINED BEHAVIOR.
> > If a value of a variable is changed more than once between two
> > sequence points, it give rises to side-effect which lead to undefined
> > behavior.
> > There is no explanation for this output supported by C standards.
> > On Jun 12, 8:14 pm, varun pahwa  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > yes the output is compiler dependent.
> >
> > > On Sun, Jun 12, 2011 at 6:35 AM, nicks 
> wrote:
> > > > but program by anika is giving *7 6 8* on gcc.but *7 6 6 *on
> > > > dev-cpp...i am wondering if the output is compiler dependent
> !!
> >
> > > > On Sun, Jun 12, 2011 at 6:33 AM, nicks 
> wrote:
> >
> > > >> no it's
> > > >> a=1 b=1
> > > >> i=2
> >
> > > >> i ran it on gcc (linux ubuntu 11.04)
> >
> > > >> On Sun, Jun 12, 2011 at 6:26 AM, sanjay ahuja <
> sanjayahuja.i...@gmail.com
> > > >> > wrote:
> >
> > > >>> with GCC the above code gives a = 1 and b = 2
> >
> > > >>> On Sun, Jun 12, 2011 at 6:39 PM, nicks  >
> > > >>> wrote:
> > > >>> > @himanshuwhat abt this ??
> >
> > > >>> > #include
> > > >>> > # include 
> > > >>> > int i=2;
> > > >>> > main()
> > > >>> > {
> > > >>> >  void add();
> > > >>> >  add(i++,--i);
> > > >>> > printf("\ni=%d \n",i);system("pause");
> > > >>> > }
> > > >>> > void add(int a ,int b)
> > > >>> > {
> > > >>> >  printf("\na=%d b=%d",a,b);
> > > >>> > }
> >
> > > >>> >  OUTPUT -
> > > >>> > a=1 b=1
> > > >>> > i=2
> >
> > > >>> > acc. to ur logic output should be -
> > > >>> > a=1 b=2
> > > >>> > i=2
> >
> > > >>> > On Sun, Jun 12, 2011 at 5:42 AM, Anika Jain <
> anika.jai...@gmail.com>
> > > >>> wrote:
> >
> > > >>> >> thanks himanshu finally i got the reason!!
> > > >>> >> :)
> >
> > > >>> >> On Sun, Jun 12, 2011 at 5:59 PM, himanshu kansal
> > > >>> >>  wrote:
> >
> > > >>> >>> @anika:cz on gcc arguemnts r eval frm right to left and
> assgnment to
> > > >>> a
> > > >>> >>> pre increment expression is delayed vry mch
> > > >>> >>> so on eval frm right to left
> > > >>> >>> frst a is incremented...(6) bt remember d new value is nt
> pushed on
> > > >>> stack
> > > >>> >>> till nw(cz assgnmnt is delayed)
> > > >>> >>> thn next value is 6...nd thn a is incremented.here being a
> post
> > > >>> >>> increment opassgnmnt is made 1st (2nd arg to fun is 6)and a
> is
> > > >>> >>> incrementd to 7
> > > >>> >>> simalrly.assgnmnt is made(1st arg is 7) and a is incremnted
> to
> > > >>> 8.
> > > >>> >>> nw d assgnmnt is made to the 3rd arg(d assgnmnt whch ws delayed
> till
> > > >>> >>> nw).hence 3rd arg becomes 8.
> > > >>> >>> so it prints 7 6 8..
> >
> > > >>> >>> On Sun, Jun 12, 2011 at 5:33 PM, Anika Jain <
> anika.jai...@gmail.com>
> > > >>> >>> wrote:
> >
> > > >>>  can anybody explain that in following code y output is coming
> to be:
> > > >>> 7 6
> > > >>>  8
> >
> > > >>>  void call(int a,int b,int c)
> > > >>>  {
> > > >>>   printf("%d %d %d",a,b,c);
> > > >>>  }
> >
> > > >>>  int main()
> > > >>>  {
> > > >>>  int a=5;
> > > >>>  call(a++,a++,++a);
> > > >>>  return 0;
> > > >>>  }
> >
> > > >>>  On Sat, Jun 11, 2011 at 8:21 PM, PRAMENDRA RATHi rathi
> > > >>>   wrote:
> >
> > > >>> > IN second program:
> > > >>> >  in function value are always push in the stack from right.
> > > >>> > so first value is --i that will make i=1 and value 1 will be
> passed
> > > >>> to
> > > >>> > function
> > > >>> > and
> > > >>> > after that i++ that's means i will be passed.
> > > >>> > so 1 will be passed and after passing value. i will changed
> to 2.
> >
> > > >>> > if u want to know why reverse order than can go through:
> >
> > > >>> >http://cs.nyu.edu/courses/fall03/V22.0201-003/c_param.html
> > > >>> > -
> > > >>> > PRAMENDRA RATHI
> > > >>> > NIT ALLAHABAD
> >
> > > >>> > On Sat, Jun 11, 2011 at 7:28 PM, Vishal Thanki <
> > > >>> vishaltha...@gmail.com>
> > > >>> > wrote:
> >
> > > >>> >> In 1st program, 2nd printf requires one more argument. And
> > > >>> basically
> > > >>> >> %a is used for printing a double value in hex. see "man 3
> printf".
> >
> > > >>> >> On Sat, Jun 11, 2011 at 5:29 PM, nicks <
> > > >>> crazy.logic.k...@gmail.com>
> > > >>> >> wrote:
> > > >>> >> > Hello friends..plz help me in understanding the following
> C

Re: [algogeeks]

2011-07-22 Thread Pankaj
https://ideone.com/tr3Q7

On Sat, Jul 23, 2011 at 12:42 AM, Pankaj  wrote:

> double **p= (double **) malloc(sizeof(double *));
>
>
> On Sat, Jul 23, 2011 at 12:40 AM, Bhavesh agrawal 
> wrote:
>
>> double pointer mean like **p
>>
>> hoe to allocate memory for this
>>
>> --
>> 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] Circular list

2011-07-22 Thread vaibhav shukla
maintain just a tail pointer

On Sat, Jul 23, 2011 at 12:45 AM, rShetty  wrote:

> Come Up with an Algorithm to implement the insertion of a node in
> circular linked list without actually traversing the list ?
>
> --
> 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.
>
>


-- 
  best wishes!!
Vaibhav
  MCA

-- 
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] Circular list

2011-07-22 Thread rShetty
Come Up with an Algorithm to implement the insertion of a node in
circular linked list without actually traversing the list ?

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

2011-07-22 Thread Pankaj
double **p= (double **) malloc(sizeof(double *));

On Sat, Jul 23, 2011 at 12:40 AM, Bhavesh agrawal wrote:

> double pointer mean like **p
>
> hoe to allocate memory for this
>
> --
> 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]

2011-07-22 Thread Rakib Ansary Saikot
int **x;
x = new int*[n];
for (int i = 0; i < n; i++){
x[i] = new int[m];
}

On Sat, Jul 23, 2011 at 1:10 AM, Bhavesh agrawal wrote:

> double pointer mean like **p
>
> hoe to allocate memory for this
>
> --
> 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]

2011-07-22 Thread Bhavesh agrawal
double pointer mean like **p

hoe to allocate memory for this

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

2011-07-22 Thread Gaurav Popli
oh sorry for above soln...it will require many passes and hence inefficient...

On Fri, Jul 22, 2011 at 9:02 PM, Gaurav Popli  wrote:
> an O(n) soln
> traveres the array...as you receive odd number put that index in
> queuewhen received an even numb check if queue is empty or
> not...if queue is empty the do nothing else swap with the head of the
> queue
>
> hope it worksit also maintains the stability of aarray...
>
> On Fri, Jul 22, 2011 at 6:39 PM, Kunal Patil  wrote:
>> @Sunny: Excellent explanation (& solution) !!
>>
>> --
>> 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]

2011-07-22 Thread Pankaj
Just like you do for int *
int *p=(int *) malloc(sizeof(int));
double *ptr_lf = (double *) malloc(sizeof(double));

On Sat, Jul 23, 2011 at 12:32 AM, hurtlocker wrote:

> how to allocate memory for a double pointer ..??
>
> --
> 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]

2011-07-22 Thread hurtlocker
how to allocate memory for a double pointer ..??

-- 
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] xplain output

2011-07-22 Thread geek forgeek
#include
void main()
{
int x;
float t;
scanf("%f",&t);
printf("%f\n",t);
x=90;
printf("%f\n",x);
{
x=1;
printf("%f\n",x);
{
x=30;
printf("%f\n",x);
}
printf("%f\n",x);
}
x==9;
printf("%f\n",x);
}

input
1.1

output
1.10
1.09
1.09
1.09
1.09
1.09

-- 
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: C OUTPUT HELP

2011-07-22 Thread sumit
+1 to t3rminal


On Jun 12, 11:38 pm, T3rminal  wrote:
> @all
> Stop guessing and making your own standards. C standards haven't
> defined anything (though in gcc arguments are processed from left to
> right) about processing arguments in a function call. And sentence
> like "assgnment to a preincrement expression is delayed vry mch"
> have no meaning . Seriously which book have you referred.
> This all fall in category of UNDEFINED BEHAVIOR.
> If a value of a variable is changed more than once between two
> sequence points, it give rises to side-effect which lead to undefined
> behavior.
> There is no explanation for this output supported by C standards.
> On Jun 12, 8:14 pm, varun pahwa  wrote:
>
>
>
>
>
>
>
> > yes the output is compiler dependent.
>
> > On Sun, Jun 12, 2011 at 6:35 AM, nicks  wrote:
> > > but program by anika is giving *7 6 8* on gcc.but *7 6 6 *on
> > > dev-cpp...i am wondering if the output is compiler dependent !!
>
> > > On Sun, Jun 12, 2011 at 6:33 AM, nicks  wrote:
>
> > >> no it's
> > >> a=1 b=1
> > >> i=2
>
> > >> i ran it on gcc (linux ubuntu 11.04)
>
> > >> On Sun, Jun 12, 2011 at 6:26 AM, sanjay ahuja  > >> > wrote:
>
> > >>> with GCC the above code gives a = 1 and b = 2
>
> > >>> On Sun, Jun 12, 2011 at 6:39 PM, nicks 
> > >>> wrote:
> > >>> > @himanshuwhat abt this ??
>
> > >>> > #include
> > >>> > # include 
> > >>> > int i=2;
> > >>> > main()
> > >>> > {
> > >>> >  void add();
> > >>> >  add(i++,--i);
> > >>> >     printf("\ni=%d \n",i);system("pause");
> > >>> > }
> > >>> > void add(int a ,int b)
> > >>> > {
> > >>> >  printf("\na=%d b=%d",a,b);
> > >>> > }
>
> > >>> >  OUTPUT -
> > >>> > a=1 b=1
> > >>> > i=2
>
> > >>> > acc. to ur logic output should be -
> > >>> > a=1 b=2
> > >>> > i=2
>
> > >>> > On Sun, Jun 12, 2011 at 5:42 AM, Anika Jain 
> > >>> wrote:
>
> > >>> >> thanks himanshu finally i got the reason!!
> > >>> >> :)
>
> > >>> >> On Sun, Jun 12, 2011 at 5:59 PM, himanshu kansal
> > >>> >>  wrote:
>
> > >>> >>> @anika:cz on gcc arguemnts r eval frm right to left and assgnment to
> > >>> a
> > >>> >>> pre increment expression is delayed vry mch
> > >>> >>> so on eval frm right to left
> > >>> >>> frst a is incremented...(6) bt remember d new value is nt pushed on
> > >>> stack
> > >>> >>> till nw(cz assgnmnt is delayed)
> > >>> >>> thn next value is 6...nd thn a is incremented.here being a post
> > >>> >>> increment opassgnmnt is made 1st (2nd arg to fun is 6)and a is
> > >>> >>> incrementd to 7
> > >>> >>> simalrly.assgnmnt is made(1st arg is 7) and a is incremnted to
> > >>> 8.
> > >>> >>> nw d assgnmnt is made to the 3rd arg(d assgnmnt whch ws delayed till
> > >>> >>> nw).hence 3rd arg becomes 8.
> > >>> >>> so it prints 7 6 8..
>
> > >>> >>> On Sun, Jun 12, 2011 at 5:33 PM, Anika Jain 
> > >>> >>> wrote:
>
> > >>>  can anybody explain that in following code y output is coming to 
> > >>>  be:
> > >>> 7 6
> > >>>  8
>
> > >>>  void call(int a,int b,int c)
> > >>>  {
> > >>>           printf("%d %d %d",a,b,c);
> > >>>  }
>
> > >>>  int main()
> > >>>  {
> > >>>  int a=5;
> > >>>  call(a++,a++,++a);
> > >>>  return 0;
> > >>>  }
>
> > >>>  On Sat, Jun 11, 2011 at 8:21 PM, PRAMENDRA RATHi rathi
> > >>>   wrote:
>
> > >>> > IN second program:
> > >>> >  in function value are always push in the stack from right.
> > >>> > so first value is --i that will make i=1 and value 1 will be 
> > >>> > passed
> > >>> to
> > >>> > function
> > >>> > and
> > >>> > after that i++ that's means i will be passed.
> > >>> > so 1 will be passed and after passing value. i will changed to 2.
>
> > >>> > if u want to know why reverse order than can go through:
>
> > >>> >http://cs.nyu.edu/courses/fall03/V22.0201-003/c_param.html
> > >>> > -
> > >>> > PRAMENDRA RATHI
> > >>> > NIT ALLAHABAD
>
> > >>> > On Sat, Jun 11, 2011 at 7:28 PM, Vishal Thanki <
> > >>> vishaltha...@gmail.com>
> > >>> > wrote:
>
> > >>> >> In 1st program, 2nd printf requires one more argument. And
> > >>> basically
> > >>> >> %a is used for printing a double value in hex. see "man 3 
> > >>> >> printf".
>
> > >>> >> On Sat, Jun 11, 2011 at 5:29 PM, nicks <
> > >>> crazy.logic.k...@gmail.com>
> > >>> >> wrote:
> > >>> >> > Hello friends..plz help me in understanding the following C
> > >>> Output
>
> > >>> >> > first one is --
>
> > >>> >> > #include
> > >>> >> > #include
> > >>> >> > main()
> > >>> >> > {
> > >>> >> > int a=5;
> > >>> >> > printf("a=%d\n",a);
> > >>> >> > printf("%a=%d",a);
> > >>> >> > getch();
> > >>> >> > }
> > >>> >> > OUTPUT -
> > >>> >> > a=5
> > >>> >> > 0x1.2ff380p-1021=4199082
>
> > >>> >> > and the other one is --
>
> > >>> >> > #include
> > >>> >> > # include 
> > >>> >> > in

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread geek forgeek
@shady and @varun ...
i hav got it
thanx both of u  :)

On Fri, Jul 22, 2011 at 11:31 AM, shady  wrote:

> @aditi the problem is scanf returns -1(EOF value) when it encounters the
> end of file, and inspite of comparing the return value of scanf he is
> comparing value of character 'a' which is not correct
> therefore the for loop should be like this :
>
> for(int t=scanf("%c",&a);t!=EOF;t=scanf("%c",&a))
>
> what varun suggested is another way of doing it :)
>
> On Fri, Jul 22, 2011 at 11:41 PM, aditi garg wrote:
>
>> @shady. so in this case we shud use a!=-1 as the condition??
>>
>>
>> On Fri, Jul 22, 2011 at 11:37 PM, shady  wrote:
>>
>>> you are scanning from stdin therefore it is not coming out of first for
>>> loop... because your terminating condition is for EOF, which is -1( scanf
>>> returns -1 ) at the end.
>>>
>>>
>>> On Fri, Jul 22, 2011 at 11:34 PM, shady  wrote:
>>>
 well you didn't mention the question, directly posted the code with no
 head-tail... wait will answer, it is not coming out of first loop


 On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek 
 wrote:

> @shady this is nt a joke..
> sorry if i am asking too stupid question
> i m getting an infinite loop here.
> not getting how?
>
>
> On Fri, Jul 22, 2011 at 10:40 AM, shady  wrote:
>
>> what kind of joke is this ?
>>
>> On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek > > wrote:
>>
>>> #include
>>> main()
>>> {
>>> FILE *fp;
>>> char a;
>>> fp=fopen("old.out","w");
>>> if(fp==0)
>>> printf("File opening error");
>>> else
>>> {
>>> for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
>>> fprintf(fp,"%c",a);
>>> fclose(fp);
>>> fp=fopen("old.out","r");
>>> while(!feof(fp))
>>> putchar(getc(fp));
>>> }
>>> }
>>>
>>> --
>>> 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.
>


>>>  --
>>> 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.
>>>
>>
>>
>>
>> --
>> Aditi Garg
>> Undergraduate Student
>> Electronics & Communication Divison
>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
>> Sector 3, Dwarka
>> New Delhi
>>
>> 9718388816
>>
>>  --
>> 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] explain plzz:output in file old.out

2011-07-22 Thread shady
@aditi the problem is scanf returns -1(EOF value) when it encounters the end
of file, and inspite of comparing the return value of scanf he is comparing
value of character 'a' which is not correct
therefore the for loop should be like this :

for(int t=scanf("%c",&a);t!=EOF;t=scanf("%c",&a))

what varun suggested is another way of doing it :)

On Fri, Jul 22, 2011 at 11:41 PM, aditi garg wrote:

> @shady. so in this case we shud use a!=-1 as the condition??
>
>
> On Fri, Jul 22, 2011 at 11:37 PM, shady  wrote:
>
>> you are scanning from stdin therefore it is not coming out of first for
>> loop... because your terminating condition is for EOF, which is -1( scanf
>> returns -1 ) at the end.
>>
>>
>> On Fri, Jul 22, 2011 at 11:34 PM, shady  wrote:
>>
>>> well you didn't mention the question, directly posted the code with no
>>> head-tail... wait will answer, it is not coming out of first loop
>>>
>>>
>>> On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek wrote:
>>>
 @shady this is nt a joke..
 sorry if i am asking too stupid question
 i m getting an infinite loop here.
 not getting how?


 On Fri, Jul 22, 2011 at 10:40 AM, shady  wrote:

> what kind of joke is this ?
>
> On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek 
> wrote:
>
>> #include
>> main()
>> {
>> FILE *fp;
>> char a;
>> fp=fopen("old.out","w");
>> if(fp==0)
>> printf("File opening error");
>> else
>> {
>> for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
>> fprintf(fp,"%c",a);
>> fclose(fp);
>> fp=fopen("old.out","r");
>> while(!feof(fp))
>> putchar(getc(fp));
>> }
>> }
>>
>> --
>> 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.

>>>
>>>
>>  --
>> 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.
>>
>
>
>
> --
> Aditi Garg
> Undergraduate Student
> Electronics & Communication Divison
> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
> Sector 3, Dwarka
> New Delhi
>
> 9718388816
>
>  --
> 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] explain plzz:output in file old.out

2011-07-22 Thread LALIT SHARMA
@script kiddle

y u r rght ...i can smell too.. :P

On Fri, Jul 22, 2011 at 11:52 PM, varun pahwa wrote:

> For breaking the first loop after the input gives EOF.
> u can write it as.
>
> for(;~scanf("%c",&a); )
>
>
> On Fri, Jul 22, 2011 at 11:43 PM, LALIT SHARMA wrote:
>
>> No, actually , a is defined as char ... and comparing char with EOF ,,
>> makes it go in infinte loop...as it never returns false.
>>
>> correct me if i am wrong...
>>
>>
>> On Fri, Jul 22, 2011 at 11:41 PM, aditi garg 
>> wrote:
>>
>>> @shady. so in this case we shud use a!=-1 as the condition??
>>>
>>>
>>> On Fri, Jul 22, 2011 at 11:37 PM, shady  wrote:
>>>
 you are scanning from stdin therefore it is not coming out of first for
 loop... because your terminating condition is for EOF, which is -1( scanf
 returns -1 ) at the end.


 On Fri, Jul 22, 2011 at 11:34 PM, shady  wrote:

> well you didn't mention the question, directly posted the code with no
> head-tail... wait will answer, it is not coming out of first loop
>
>
> On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek 
> wrote:
>
>> @shady this is nt a joke..
>> sorry if i am asking too stupid question
>> i m getting an infinite loop here.
>> not getting how?
>>
>>
>> On Fri, Jul 22, 2011 at 10:40 AM, shady  wrote:
>>
>>> what kind of joke is this ?
>>>
>>> On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek <
>>> geekhori...@gmail.com> wrote:
>>>
 #include
 main()
 {
 FILE *fp;
 char a;
 fp=fopen("old.out","w");
 if(fp==0)
 printf("File opening error");
 else
 {
 for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
 fprintf(fp,"%c",a);
 fclose(fp);
 fp=fopen("old.out","r");
 while(!feof(fp))
 putchar(getc(fp));
 }
 }

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

>>>
>>>
>>>
>>> --
>>> Aditi Garg
>>> Undergraduate Student
>>> Electronics & Communication Divison
>>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
>>> Sector 3, Dwarka
>>> New Delhi
>>>
>>> 9718388816
>>>
>>>  --
>>> 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.
>>>
>>
>>
>>
>> --
>> Lalit Kishore Sharma,
>>
>> IIIT Allahabad,
>> 7th Sem.
>> Contact No. - +919670057056 , +918957935169
>>
>>
>>  --
>> 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.
>>
>
>
>
> --
> Varun Pahwa
> B.Tech (IT)
> 7th Sem.
> Indian Institute of Information Technology Allahabad.
> Ph : 09793899112
> Official Email :: rit2008...@iiita.ac.in
> Another Email :: varunpahwa.ii...@gmail.com
>
> People who fail to plan are those who plan to fail.

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread varun pahwa
For breaking the first loop after the input gives EOF.
u can write it as.

for(;~scanf("%c",&a); )

On Fri, Jul 22, 2011 at 11:43 PM, LALIT SHARMA  wrote:

> No, actually , a is defined as char ... and comparing char with EOF ,,
> makes it go in infinte loop...as it never returns false.
>
> correct me if i am wrong...
>
>
> On Fri, Jul 22, 2011 at 11:41 PM, aditi garg wrote:
>
>> @shady. so in this case we shud use a!=-1 as the condition??
>>
>>
>> On Fri, Jul 22, 2011 at 11:37 PM, shady  wrote:
>>
>>> you are scanning from stdin therefore it is not coming out of first for
>>> loop... because your terminating condition is for EOF, which is -1( scanf
>>> returns -1 ) at the end.
>>>
>>>
>>> On Fri, Jul 22, 2011 at 11:34 PM, shady  wrote:
>>>
 well you didn't mention the question, directly posted the code with no
 head-tail... wait will answer, it is not coming out of first loop


 On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek 
 wrote:

> @shady this is nt a joke..
> sorry if i am asking too stupid question
> i m getting an infinite loop here.
> not getting how?
>
>
> On Fri, Jul 22, 2011 at 10:40 AM, shady  wrote:
>
>> what kind of joke is this ?
>>
>> On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek > > wrote:
>>
>>> #include
>>> main()
>>> {
>>> FILE *fp;
>>> char a;
>>> fp=fopen("old.out","w");
>>> if(fp==0)
>>> printf("File opening error");
>>> else
>>> {
>>> for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
>>> fprintf(fp,"%c",a);
>>> fclose(fp);
>>> fp=fopen("old.out","r");
>>> while(!feof(fp))
>>> putchar(getc(fp));
>>> }
>>> }
>>>
>>> --
>>> 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.
>


>>>  --
>>> 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.
>>>
>>
>>
>>
>> --
>> Aditi Garg
>> Undergraduate Student
>> Electronics & Communication Divison
>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
>> Sector 3, Dwarka
>> New Delhi
>>
>> 9718388816
>>
>>  --
>> 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.
>>
>
>
>
> --
> Lalit Kishore Sharma,
>
> IIIT Allahabad,
> 7th Sem.
> Contact No. - +919670057056 , +918957935169
>
>
>  --
> 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.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

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

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread SkRiPt KiDdIe
I smell something BONe - Y  :P

-- 
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] explain plzz:output in file old.out

2011-07-22 Thread LALIT SHARMA
No, actually , a is defined as char ... and comparing char with EOF ,, makes
it go in infinte loop...as it never returns false.

correct me if i am wrong...

On Fri, Jul 22, 2011 at 11:41 PM, aditi garg wrote:

> @shady. so in this case we shud use a!=-1 as the condition??
>
>
> On Fri, Jul 22, 2011 at 11:37 PM, shady  wrote:
>
>> you are scanning from stdin therefore it is not coming out of first for
>> loop... because your terminating condition is for EOF, which is -1( scanf
>> returns -1 ) at the end.
>>
>>
>> On Fri, Jul 22, 2011 at 11:34 PM, shady  wrote:
>>
>>> well you didn't mention the question, directly posted the code with no
>>> head-tail... wait will answer, it is not coming out of first loop
>>>
>>>
>>> On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek wrote:
>>>
 @shady this is nt a joke..
 sorry if i am asking too stupid question
 i m getting an infinite loop here.
 not getting how?


 On Fri, Jul 22, 2011 at 10:40 AM, shady  wrote:

> what kind of joke is this ?
>
> On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek 
> wrote:
>
>> #include
>> main()
>> {
>> FILE *fp;
>> char a;
>> fp=fopen("old.out","w");
>> if(fp==0)
>> printf("File opening error");
>> else
>> {
>> for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
>> fprintf(fp,"%c",a);
>> fclose(fp);
>> fp=fopen("old.out","r");
>> while(!feof(fp))
>> putchar(getc(fp));
>> }
>> }
>>
>> --
>> 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.

>>>
>>>
>>  --
>> 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.
>>
>
>
>
> --
> Aditi Garg
> Undergraduate Student
> Electronics & Communication Divison
> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
> Sector 3, Dwarka
> New Delhi
>
> 9718388816
>
>  --
> 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.
>



-- 
Lalit Kishore Sharma,

IIIT Allahabad,
7th Sem.
Contact No. - +919670057056 , +918957935169

-- 
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] explain plzz:output in file old.out

2011-07-22 Thread aditi garg
@shady. so in this case we shud use a!=-1 as the condition??

On Fri, Jul 22, 2011 at 11:37 PM, shady  wrote:

> you are scanning from stdin therefore it is not coming out of first for
> loop... because your terminating condition is for EOF, which is -1( scanf
> returns -1 ) at the end.
>
>
> On Fri, Jul 22, 2011 at 11:34 PM, shady  wrote:
>
>> well you didn't mention the question, directly posted the code with no
>> head-tail... wait will answer, it is not coming out of first loop
>>
>>
>> On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek wrote:
>>
>>> @shady this is nt a joke..
>>> sorry if i am asking too stupid question
>>> i m getting an infinite loop here.
>>> not getting how?
>>>
>>>
>>> On Fri, Jul 22, 2011 at 10:40 AM, shady  wrote:
>>>
 what kind of joke is this ?

 On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek 
 wrote:

> #include
> main()
> {
> FILE *fp;
> char a;
> fp=fopen("old.out","w");
> if(fp==0)
> printf("File opening error");
> else
> {
> for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
> fprintf(fp,"%c",a);
> fclose(fp);
> fp=fopen("old.out","r");
> while(!feof(fp))
> putchar(getc(fp));
> }
> }
>
> --
> 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.
>>>
>>
>>
>  --
> 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.
>



-- 
Aditi Garg
Undergraduate Student
Electronics & Communication Divison
NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
Sector 3, Dwarka
New Delhi

9718388816

-- 
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] explain plzz:output in file old.out

2011-07-22 Thread shady
you are scanning from stdin therefore it is not coming out of first for
loop... because your terminating condition is for EOF, which is -1( scanf
returns -1 ) at the end.

On Fri, Jul 22, 2011 at 11:34 PM, shady  wrote:

> well you didn't mention the question, directly posted the code with no
> head-tail... wait will answer, it is not coming out of first loop
>
>
> On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek wrote:
>
>> @shady this is nt a joke..
>> sorry if i am asking too stupid question
>> i m getting an infinite loop here.
>> not getting how?
>>
>>
>> On Fri, Jul 22, 2011 at 10:40 AM, shady  wrote:
>>
>>> what kind of joke is this ?
>>>
>>> On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek wrote:
>>>
 #include
 main()
 {
 FILE *fp;
 char a;
 fp=fopen("old.out","w");
 if(fp==0)
 printf("File opening error");
 else
 {
 for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
 fprintf(fp,"%c",a);
 fclose(fp);
 fp=fopen("old.out","r");
 while(!feof(fp))
 putchar(getc(fp));
 }
 }

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

-- 
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] explain plzz:output in file old.out

2011-07-22 Thread shady
well you didn't mention the question, directly posted the code with no
head-tail... wait will answer, it is not coming out of first loop

On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek wrote:

> @shady this is nt a joke..
> sorry if i am asking too stupid question
> i m getting an infinite loop here.
> not getting how?
>
>
> On Fri, Jul 22, 2011 at 10:40 AM, shady  wrote:
>
>> what kind of joke is this ?
>>
>> On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek wrote:
>>
>>> #include
>>> main()
>>> {
>>> FILE *fp;
>>> char a;
>>> fp=fopen("old.out","w");
>>> if(fp==0)
>>> printf("File opening error");
>>> else
>>> {
>>> for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
>>> fprintf(fp,"%c",a);
>>> fclose(fp);
>>> fp=fopen("old.out","r");
>>> while(!feof(fp))
>>> putchar(getc(fp));
>>> }
>>> }
>>>
>>> --
>>> 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.
>

-- 
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] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Vishal Jain
I think Aditi's solution is correct. I was doing the same thing using XOR
function... So basically I was saying to use XOR and interviewer was asking
for something better... I could not find this solution...

Thanks Aditi.

Thanks & Regards
Vishal Jain
MNo: +91-9540611889
Tweet @jainvis
Blog @ jainvish.blogspot.com
Success taste better when target achieved is bigger.

P *We have a responsibility to the environment.*

*Before printing this e-mail or any other document, let's ask
ourselves whether we need a hard copy.*




On Fri, Jul 22, 2011 at 10:19 PM, aditi garg wrote:

> I think this can be answered like dis...
> let us say that the persons have decided amongst themselves that if the the
> number of people wearing white in front of dem is even he wud say white and
> if odd he wud say black
> Now suppose the 100th person counts the number of hats and finds it to be
> even... he wud say white...
> now the 99th person will do the same...if he still finds the number to be
> even and since the 100th person sed white(i.e even) he would say black...now
> if the 100th person had sed black (ie odd white) and the count comes out to
> be even thus 99 wud be wearing a white hat...
> Now that 98th person knows dat 99 had sed the correct hat and using the
> same method can say the correct hat color...thus all can be saved except the
> 100th prisoner...
> Also note dat the 100th prisoner also has a 50% chance to survive...
>
> Hope dis helps :)
>
>
> On Fri, Jul 22, 2011 at 10:05 PM, Shubham Maheshwari <
> shubham@gmail.com> wrote:
>
>> could some1 plz post the xplainations ...
>>
>>
>> On Fri, Jul 22, 2011 at 8:04 PM, Pankaj wrote:
>>
>>> Chetan,
>>>
>>> No. How could you relate this problem with that? Do you find something
>>> similar?
>>>
>>> ~
>>> Pankaj
>>>
>>>
>>> On Fri, Jul 22, 2011 at 8:01 PM, chetan kapoor <
>>> chetankapoor...@gmail.com> wrote:
>>>
 josehus problem???


 On Fri, Jul 22, 2011 at 7:57 PM, Pankaj wrote:

> Skipp Riddle,
> Yes.
> 100th prisoner will risk his life. Similar puzzle was discuss recently.
> Does anyone remember the name or thread?
>
>
> ~
> Pankaj
>
>
> On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe  > wrote:
>
>> Worst case 99 get released.
>> Is that correct..?
>>
>>  --
>> 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.

>>>
>>>  --
>>> 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.
>>
>
>
>
> --
> Aditi Garg
> Undergraduate Student
> Electronics & Communication Divison
> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
> Sector 3, Dwarka
> New Delhi
>
> 9718388816
>
>  --
> 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, 

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread geek forgeek
@shady this is nt a joke..
sorry if i am asking too stupid question
i m getting an infinite loop here.
not getting how?

On Fri, Jul 22, 2011 at 10:40 AM, shady  wrote:

> what kind of joke is this ?
>
> On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek wrote:
>
>> #include
>> main()
>> {
>> FILE *fp;
>> char a;
>> fp=fopen("old.out","w");
>> if(fp==0)
>> printf("File opening error");
>> else
>> {
>> for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
>> fprintf(fp,"%c",a);
>> fclose(fp);
>> fp=fopen("old.out","r");
>> while(!feof(fp))
>> putchar(getc(fp));
>> }
>> }
>>
>> --
>> 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] explain plzz:output in file old.out

2011-07-22 Thread shady
what kind of joke is this ?

On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek wrote:

> #include
> main()
> {
> FILE *fp;
> char a;
> fp=fopen("old.out","w");
> if(fp==0)
> printf("File opening error");
> else
> {
> for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
> fprintf(fp,"%c",a);
> fclose(fp);
> fp=fopen("old.out","r");
> while(!feof(fp))
> putchar(getc(fp));
> }
> }
>
> --
> 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] explain plzz:output in file old.out

2011-07-22 Thread geek forgeek
#include
main()
{
FILE *fp;
char a;
fp=fopen("old.out","w");
if(fp==0)
printf("File opening error");
else
{
for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
fprintf(fp,"%c",a);
fclose(fp);
fp=fopen("old.out","r");
while(!feof(fp))
putchar(getc(fp));
}
}

-- 
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: Microsoft Question!

2011-07-22 Thread naveen ms
thank u:)

-- 
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: subwords in a given word!

2011-07-22 Thread Shubham Maheshwari
how are you gonna do it if the originl strng contains repeated letters ...

On Fri, Jul 22, 2011 at 3:33 PM, shady  wrote:

> what algorithm, print it subsequently
> is there any ?
>
>
> On Fri, Jul 22, 2011 at 3:24 PM, DeeJJ..! wrote:
>
>> @sunny...yaa..but can u just describe the algorithm..:)
>>
>> On Jul 22, 2:51 am, sunny agrawal  wrote:
>> > n+(n-1) +(n-2)++1 = O(n^2)
>> >
>> >
>> >
>> > On Fri, Jul 22, 2011 at 3:16 PM, DeeJJ..! 
>> wrote:
>> > > Q)complexity to find subwords in a given word?
>> > > ex: abcde
>> > > ans: a b c d e
>> > >   ab bc cd de
>> > >   abc bcd cde
>> > >   abcd bcde
>> > >   abcde
>> >
>> > > --
>> > > 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.
>> >
>> > --
>> > Sunny Aggrawal
>> > B-Tech IV year,CSI
>> > Indian Institute Of Technology,Roorkee
>>
>> --
>> 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] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread aditi garg
I think this can be answered like dis...
let us say that the persons have decided amongst themselves that if the the
number of people wearing white in front of dem is even he wud say white and
if odd he wud say black
Now suppose the 100th person counts the number of hats and finds it to be
even... he wud say white...
now the 99th person will do the same...if he still finds the number to be
even and since the 100th person sed white(i.e even) he would say black...now
if the 100th person had sed black (ie odd white) and the count comes out to
be even thus 99 wud be wearing a white hat...
Now that 98th person knows dat 99 had sed the correct hat and using the same
method can say the correct hat color...thus all can be saved except the
100th prisoner...
Also note dat the 100th prisoner also has a 50% chance to survive...

Hope dis helps :)

On Fri, Jul 22, 2011 at 10:05 PM, Shubham Maheshwari
wrote:

> could some1 plz post the xplainations ...
>
>
> On Fri, Jul 22, 2011 at 8:04 PM, Pankaj  wrote:
>
>> Chetan,
>>
>> No. How could you relate this problem with that? Do you find something
>> similar?
>>
>> ~
>> Pankaj
>>
>>
>> On Fri, Jul 22, 2011 at 8:01 PM, chetan kapoor > > wrote:
>>
>>> josehus problem???
>>>
>>>
>>> On Fri, Jul 22, 2011 at 7:57 PM, Pankaj wrote:
>>>
 Skipp Riddle,
 Yes.
 100th prisoner will risk his life. Similar puzzle was discuss recently.
 Does anyone remember the name or thread?


 ~
 Pankaj


 On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe 
 wrote:

> Worst case 99 get released.
> Is that correct..?
>
>  --
> 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.
>>>
>>
>>  --
>> 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.
>



-- 
Aditi Garg
Undergraduate Student
Electronics & Communication Divison
NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
Sector 3, Dwarka
New Delhi

9718388816

-- 
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: MICROSOFT!!!!

2011-07-22 Thread siva viknesh
both intern and interview.

all 10 ques were MCQ type

os based :
1.   u ve a disk , 1 represents a 'valid read' (I forgot d exact
term!!!) and 0 represents 'invalid read' gn. a hexadecimal string
DFE00454AB ... find the nearest percentage of valid read?

2. gn. a CFG

s->AB
A->a|BaB
B->bb

..state which of the following statement is FALSE (I can remeber this
much oly!)

3. gn a inorder traversal, find the equivalent preorder  traversal

.all other 7 ques were guess the o/p of c prog..i dont remeber
exactlydifficulty level was moderate only!!!


On Jul 22, 9:16 pm, naveen ms  wrote:
> @siva viknesh:it would be of great help if u post the questions that u
> remember...(in that 10 questions)...
>
> with regards
> naveen

-- 
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] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Shubham Maheshwari
could some1 plz post the xplainations ...

On Fri, Jul 22, 2011 at 8:04 PM, Pankaj  wrote:

> Chetan,
>
> No. How could you relate this problem with that? Do you find something
> similar?
>
> ~
> Pankaj
>
>
> On Fri, Jul 22, 2011 at 8:01 PM, chetan kapoor 
> wrote:
>
>> josehus problem???
>>
>>
>> On Fri, Jul 22, 2011 at 7:57 PM, Pankaj wrote:
>>
>>> Skipp Riddle,
>>> Yes.
>>> 100th prisoner will risk his life. Similar puzzle was discuss recently.
>>> Does anyone remember the name or thread?
>>>
>>>
>>> ~
>>> Pankaj
>>>
>>>
>>> On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe 
>>> wrote:
>>>
 Worst case 99 get released.
 Is that correct..?

  --
 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.
>>
>
>  --
> 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] Re: Microsoft Question!

2011-07-22 Thread Shubham Maheshwari
thnx ...
:D

On Fri, Jul 22, 2011 at 9:19 PM, sagar pareek  wrote:

> gr8 shubham
>
> On Fri, Jul 22, 2011 at 1:42 PM, Shubham Maheshwari  > wrote:
>
>> x = 0;
>> while( n ){
>> x <<= 1;
>> x = x | ( n & 1);
>> n >>= 1;
>> }
>>
>> return x;
>>
>> On Fri, Jul 22, 2011 at 1:31 PM, Puneet Gautam 
>> wrote:
>>
>>> sorry guys.. dont check the above siolution.. its wrong...!!!
>>> misread it..
>>>
>>>
>>> On 7/22/11, Puneet Gautam  wrote:
>>> > check this out: Considering all 4 bytes of int with no left or right
>>> > shifts..!!
>>> > ;)
>>> >
>>> > main()
>>> > { unsigned int i,j,k,no=1;
>>> >   j=4;
>>> >   for(k=0;k<32;k++)
>>> >no*=2;
>>> >   no=no-j;
>>> >   cout<<"\n The reverse is"<>> >   getch();
>>> >   return 0;
>>> >   }
>>> >
>>> > On 7/22/11, nicks  wrote:
>>> >> see this
>>> >>
>>> >> http://geeksforgeeks.org/?p=726
>>> >>
>>> >> On Fri, Jul 22, 2011 at 4:29 AM, adhyetha 
>>> >> wrote:
>>> >>
>>> >>> reverse(int n)
>>> >>> {
>>> >>>int i, result = 0;
>>> >>>
>>> >>>for(i = 0; i < 32; i++)
>>> >>>   result |= ((n >> i) & 1) << (31 - i);
>>> >>> }
>>> >>>
>>> >>>
>>> >>>  assuming 32 bit integer to be reversed and assuming all 32 bits
>>> >>> to be reversed.. i.e 100101 reverses to
>>> >>> 10100100
>>> >>>
>>> >>> --
>>> >>> 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.
>>>
>>>
>>  --
>> 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
> SAGAR PAREEK
> COMPUTER SCIENCE AND ENGINEERING
> 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.
>

-- 
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: MICROSOFT!!!!

2011-07-22 Thread naveen ms
@siva viknesh:it would be of great help if u post the questions that u
remember...(in that 10 questions)...

with regards
naveen

-- 
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: Puzzle and solution

2011-07-22 Thread sagar pareek
thanks
its almost same  :)
i was hoping for a diff answer (if exists)

On Fri, Jul 22, 2011 at 4:25 PM, Rajeev Kumar wrote:

> Please check this : http://www.techinterview.org/post/526313890/bad-king
>
> On Tue, Jul 19, 2011 at 8:43 PM, sagar pareek wrote:
>
>> hey guys pls tell any other better solution ...
>>
>>
>> On Tue, Jul 19, 2011 at 6:41 PM, sagar pareek wrote:
>>
>>> Question :-
>>>
>>>
>>>
>>> Once upon a time in ancient times there was a king who was very fond of
>>> wines.  He had a huge cellar, which had 1000 different varieties of wine
>>> all in different caskets (1000 caskets in all).  In the adjoining
>>> kingdom there was a queen who was envious of the king’s huge wine
>>> collection.  After some time when she could not bear it any more she
>>> conspired to kill her by poisoning all his wine caskets.  So she one
>>> sentry to poison all the caskets, but no sooner had the sentry poisoned only
>>> one wine casket that he was caught and killed by the Royal guards.  Now
>>> the king had a major problem in his hand so as to identify the right casket,
>>> which he gave to the Minister.  Now the position had two peculiar
>>> qualities
>>>
>>>
>>>
>>>  Anyone who takes even one drop of poison will die.
>>>
>>>  But, he will die only after one month.
>>>
>>>
>>>
>>>  The king also gave the Minister 10 prisoners who could be used
>>> as tasters, cause there lives was of no consequence to the king of kingdom
>>> for that matter, and the Minister was given one month to find the poisoned
>>> casket.  Is it possible for the Minister to find out in one month?  If
>>> so how? If not then how many months are required?
>>>
>>>
>>>
>>>
>>>
>>> My solution :-
>>>
>>> This can be done in one month
>>>
>>> Think the solution in binary
>>>
>>> ok first i wanna ask u a question :- how many bits are needed to
>>> represent the number 1000 ?
>>> yeah u r right -> 10 bits
>>>
>>> so here is the solution
>>> let if any prisoner alive it mean it doesnt die and it will be
>>> represented by 1 else if he dies then he will be represented by 0
>>> number the prisoners from 0-9 with 0 the right most (LSB)
>>> now what will be binary representation of 0 ? 00
>>> so if 0th bottle is poisoned then all prisoners must die so taste the
>>> 0th(actually 1st) wine to all the prisoners.
>>> what is binary representation of 1? 01
>>> so taste the 1st(actually 2nd) wine to all except the 0th prisoner.
>>> for 2nd, all except 1st (considering 0th as lowest bit) one
>>>
>>> and so on.
>>> so at the end if suppose 6th and 2nd prisoner(consider 0 min and 9 max)
>>> left alive then answer will be :- 1*2^5+1*2^1 +1  (note:- here ^= power)
>>>
>>>
>>> if anyone have more general solution pls let me know
>>>
>>> *I hope this is useful  :) :)*
>>>
>>>
>>>
>>> --
>>> **Regards
>>> SAGAR PAREEK
>>> COMPUTER SCIENCE AND ENGINEERING
>>> NIT ALLAHABAD
>>>
>>>
>>
>>
>> --
>> **Regards
>> SAGAR PAREEK
>> COMPUTER SCIENCE AND ENGINEERING
>> 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.
>>
>
>
>
> --
> Thank You
> Rajeev 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.
>



-- 
**Regards
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
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.



Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11

Thanx for pointitn out the case :) Hope dis wil wrk.
https://ideone.com/0LNkW

On , Pankaj  wrote:







aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwzzyyzzabc
output:



Length of largest unique substring : 51
Sorry it gt posted thrice.







On Jul 22, 7:50 pm, vaibhavmitta...@gmail.com wrote:



> https://ideone.com/kzo2L



>



> Regards



> Vaibhav Mittal



> Computer Science



> Netaji Subhas Institute Of Technology



> Delhi.



>




> On , Pankaj jatka.oppimi...@gmail.com> wrote:



>



>



>



>



>



>



>



> > Vaibhav, Ok write your code and paste on ideone. It should be easy and



> > quick to code :)




> > On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com> wrote:



> > U hv got my algo completely wrong. Gimme a smaller test case so that i



> > may wrk it out fr u. This one is freakingly large :P.



> > Regards



> > Vaibhav Mittal



> > Computer Science



> > Netaji Subhas Institute Of Technology



> > Delhi.




> > On , Pankaj jatka.oppimi...@gmail.com> wrote:



> > > abcdeaifjlbmnodpq



> > > For this once you encounter a at 6th position, You can update your



> > max.Now You will have to do following operation.



> > > First clear all the hash.



> > > 2. You now can not start from 6th position. You will have to do back



> > and start from 2 position that is b.



>



> > > Right?



> > > What is the maximum unique string in above test case?



> > > Try printing each sub string formed whenever you hit a duplicate.



> > > It's still O(N) though if we have constant number of characters :)



>




> > > On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com> wrote:



>


> > > Have a look again. I traverse the string just once performing  
updation


> > on variables low, high, max. I assume array operations to be O(1)  
(which


> > they are). OVerall complexity is O(n).Once I hit a duplicate i change  
my



> > low, high and A accordingly and move forward.



>



> > > Regards



> > > Vaibhav Mittal



> > > Computer Science



> > > Netaji Subhas Institute Of Technology



> > > Delhi.



>




> > > On , Pankaj jatka.oppimi...@gmail.com> wrote:



>


> > > > VaibhavWhat do you think the complexity of your algo is. And once  
you



> > hit an duplicate, from where will you start again?



> > > > Try for this example



> > > > abcdeaifjlbmnodpq.


> > > > It will be still O(26*n) as at max, we would have to start from  
each



> > letter and go forward maximum 26times( if we reach 26 then we have it



> > largest possible unique string). Otherwise keep checking.



>


> > > > So overall maximum complexity can be (MAX*n) where max will be  
unique



> > letters.



> > > > Abhishek, I think the final complexity can never be O(n^2) if you




> > only consider unique letters az.



> > > > The suggested soln is purely bruteforce. If anyone can think of a



> > better solution then please reply.



>



> > > > Cheers



> > > > Pankaj



>




> > > > On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com>



> > wrote:



>


> > > > VaibhavWhat do you thing the complexity of your algo is. And once  
you



> > hit an duplicate, from where will you start again?



>




> > > > On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com> wrote:



>



> > > > String is "abcded"



> > > > l =0, h = 0



>



> > > > i = 1, l = 0, h = 1, max = 1, A[a]=1



> > > > i = 2, l = 0, h = 2, max = 2, A[b] = 2



>



> > > > i = 3, l = 0, h = 3, max = 3, A[c] = 3



> > > > i = 4, l = 0, h = 4, max = 4, A[d] = 4



>



> > > > i = 5, l = 0, h = 5, max = 5, A[e] = 5


> > > > i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] =  
5, h



> > = 6, max = max(5, 6-4)= max(5, 2) = 5



>



> > > > hence ur ans = 5



>



> > > > Regards



> > > > Vaibhav Mittal



> > > > Computer Science



> > > > Netaji Subhas Institute Of Technology



> > > > Delhi.



>





> > > > On , Interstellar Overdrive abhi123khat...@gmail.com> wrote:



>


> > > > > @svm11: Take the case with original string "abcded" output  
should



> > be 5 but your algo will give the answer as 0.



>



> > > > > --



>


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



>



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




Re: [algogeeks] Re: Microsoft Question!

2011-07-22 Thread sagar pareek
gr8 shubham

On Fri, Jul 22, 2011 at 1:42 PM, Shubham Maheshwari
wrote:

> x = 0;
> while( n ){
> x <<= 1;
> x = x | ( n & 1);
> n >>= 1;
> }
>
> return x;
>
> On Fri, Jul 22, 2011 at 1:31 PM, Puneet Gautam wrote:
>
>> sorry guys.. dont check the above siolution.. its wrong...!!!
>> misread it..
>>
>>
>> On 7/22/11, Puneet Gautam  wrote:
>> > check this out: Considering all 4 bytes of int with no left or right
>> > shifts..!!
>> > ;)
>> >
>> > main()
>> > { unsigned int i,j,k,no=1;
>> >   j=4;
>> >   for(k=0;k<32;k++)
>> >no*=2;
>> >   no=no-j;
>> >   cout<<"\n The reverse is"<> >   getch();
>> >   return 0;
>> >   }
>> >
>> > On 7/22/11, nicks  wrote:
>> >> see this
>> >>
>> >> http://geeksforgeeks.org/?p=726
>> >>
>> >> On Fri, Jul 22, 2011 at 4:29 AM, adhyetha 
>> >> wrote:
>> >>
>> >>> reverse(int n)
>> >>> {
>> >>>int i, result = 0;
>> >>>
>> >>>for(i = 0; i < 32; i++)
>> >>>   result |= ((n >> i) & 1) << (31 - i);
>> >>> }
>> >>>
>> >>>
>> >>>  assuming 32 bit integer to be reversed and assuming all 32 bits
>> >>> to be reversed.. i.e 100101 reverses to
>> >>> 10100100
>> >>>
>> >>> --
>> >>> 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.
>>
>>
>  --
> 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
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
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.



Re: [algogeeks] Coding..........

2011-07-22 Thread Gaurav Popli
an O(n) soln
traveres the array...as you receive odd number put that index in
queuewhen received an even numb check if queue is empty or
not...if queue is empty the do nothing else swap with the head of the
queue

hope it worksit also maintains the stability of aarray...

On Fri, Jul 22, 2011 at 6:39 PM, Kunal Patil  wrote:
> @Sunny: Excellent explanation (& solution) !!
>
> --
> 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: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Pankaj
aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwzzyyzzabc

output:


Length of largest unique substring : 51

Sorry it gt posted thrice.
>
> On Jul 22, 7:50 pm, vaibhavmitta...@gmail.com wrote:
> > https://ideone.com/kzo2L
> >
> > Regards
> > Vaibhav Mittal
> > Computer Science
> > Netaji Subhas Institute Of Technology
> > Delhi.
> >
> > On , Pankaj  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Vaibhav, Ok write your code and paste on ideone. It should be easy and
>
> > > quick to code :)
> > > On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com> wrote:
> > > U hv got my algo completely wrong. Gimme a smaller test case so that i
>
> > > may wrk it out fr u. This one is freakingly large :P.
> > > Regards
> > > Vaibhav Mittal
> > > Computer Science
> > > Netaji Subhas Institute Of Technology
> > > Delhi.
> > > On , Pankaj jatka.oppimi...@gmail.com> wrote:
> > > > abcdeaifjlbmnodpq
> > > > For this once you encounter a at 6th position, You can update your
> > > max.Now You will have to do following operation.
> > > > First clear all the hash.
> > > > 2. You now can not start from 6th position. You will have to do back
>
> > > and start from 2 position that is b.
> >
> > > > Right?
> > > > What is the maximum unique string in above test case?
> > > > Try printing each sub string formed whenever you hit a duplicate.
> > > > It's still O(N) though if we have constant number of characters :)
> >
> > > > On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com> wrote:
> >
> > > > Have a look again. I traverse the string just once performing
> updation
> > > on variables low, high, max. I assume array operations to be O(1)
> (which
> > > they are). OVerall complexity is O(n).Once I hit a duplicate i change
> my
> > > low, high and A accordingly and move forward.
> >
> > > > Regards
> > > > Vaibhav Mittal
> > > > Computer Science
> > > > Netaji Subhas Institute Of Technology
> > > > Delhi.
> >
> > > > On , Pankaj jatka.oppimi...@gmail.com> wrote:
> >
> > > > > VaibhavWhat do you think the complexity of your algo is. And once
> you
> > > hit an duplicate, from where will you start again?
> > > > > Try for this example
> > > > > abcdeaifjlbmnodpq.
> > > > > It will be still O(26*n) as at max, we would have to start from
> each
> > > letter and go forward maximum 26times( if we reach 26 then we have it
> > > largest possible unique string). Otherwise keep checking.
> >
> > > > > So overall maximum complexity can be (MAX*n) where max will be
> unique
> > > letters.
> > > > > Abhishek, I think the final complexity can never be O(n^2) if you
> > > only consider unique letters az.
> > > > > The suggested soln is purely bruteforce. If anyone can think of a
> > > better solution then please reply.
> >
> > > > > Cheers
> > > > > Pankaj
> >
> > > > > On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com>
>
> > > wrote:
> >
> > > > > VaibhavWhat do you thing the complexity of your algo is. And once
> you
> > > hit an duplicate, from where will you start again?
> >
> > > > > On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com> wrote:
> >
> > > > > String is "abcded"
> > > > > l =0, h = 0
> >
> > > > > i = 1, l = 0, h = 1, max = 1, A[a]=1
> > > > > i = 2, l = 0, h = 2, max = 2, A[b] = 2
> >
> > > > > i = 3, l = 0, h = 3, max = 3, A[c] = 3
> > > > > i = 4, l = 0, h = 4, max = 4, A[d] = 4
> >
> > > > > i = 5, l = 0, h = 5, max = 5, A[e] = 5
> > > > > i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5,
> h
> > > = 6, max = max(5, 6-4)= max(5, 2) = 5
> >
> > > > > hence ur ans = 5
> >
> > > > > Regards
> > > > > Vaibhav Mittal
> > > > > Computer Science
> > > > > Netaji Subhas Institute Of Technology
> > > > > Delhi.
> >
> > > > > On , Interstellar Overdrive abhi123khat...@gmail.com> wrote:
> >
> > > > > > @svm11: Take the case with original string "abcded" output should
>
> > > be 5 but your algo will give the answer as 0.
> >
> > > > > > --
> >
> > > > > > 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/-/hG6ZNcG5fMMJ.
> >
> > > > > > 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
>
> > > G

Re: [algogeeks] Re: MICROSOFT!!!!

2011-07-22 Thread Prakash D
post the 10 questions plz

On Fri, Jul 22, 2011 at 8:29 PM, shady  wrote:

> what was it ? job interview questions or intern ?
>
> gcd can always be found in O(log(larger number)) , sorry, couldnt
> understand the complexity in that ?
>
>
> On Fri, Jul 22, 2011 at 8:22 PM, siva viknesh wrote:
>
>> @ankur.. as u said i m posting today :) :)
>>
>> 10 questions c output, one compiler based(CFG) ,one OS
>> based (when reading internally it was just a simple percentage
>> calculation question)..
>>
>> +3 for correct ans..
>> -2 for wrong ans...Damn it.. i dint notice d negative marking and
>> attended all :(
>>
>> ...questions were not so tough (neither so easy :P) and all , u just
>> need to think aloud
>>
>> 10 marks :
>>
>> 1. Find gcd of 2 numbers U & V in O(log UV)^2
>>
>> 2.   Test cases for finger print recognition say in a laptop to login
>>
>> 3. Design question..for billing , u have barcode, barcode number,
>> item price, taxes, discounts for items (some criteria were given and u
>> have to  design an algo for calculating discount) and then finally
>> compute Net pricewhat DS u ll usehow ll u improve this
>> design...State advantages and disadvantages.
>>
>> u have to think aloud and innovative ..thats it :)
>>
>> On Jul 18, 8:46 pm, Ankur Garg  wrote:
>> > post on 22nd itself bro ;) ..there is a written  test on 23rd
>> >
>> > On Mon, Jul 18, 2011 at 8:45 PM, siva viknesh > >wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > @all..thanks a lotsure ll post the questions after 22nd :)
>> >
>> > > On Jul 18, 8:13 pm, sourabh jakhar  wrote:
>> > > > study basic well they give a lot of emphasis on them
>> >
>> > > > On Mon, Jul 18, 2011 at 8:41 PM, SkRiPt KiDdIe <
>> anuragmsi...@gmail.com
>> > > >wrote:
>> >
>> > > > > After 22nd plz post ur questions ... !!
>> > > > > It wud be of great HelP.
>> >
>> > > > > --
>> > > > > 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.
>> >
>> > > > --
>> > > > SOURABH JAKHAR,(CSE)(Final 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
>> 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.
>

-- 
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: MICROSOFT!!!!

2011-07-22 Thread shady
what was it ? job interview questions or intern ?

gcd can always be found in O(log(larger number)) , sorry, couldnt understand
the complexity in that ?

On Fri, Jul 22, 2011 at 8:22 PM, siva viknesh wrote:

> @ankur.. as u said i m posting today :) :)
>
> 10 questions c output, one compiler based(CFG) ,one OS
> based (when reading internally it was just a simple percentage
> calculation question)..
>
> +3 for correct ans..
> -2 for wrong ans...Damn it.. i dint notice d negative marking and
> attended all :(
>
> ...questions were not so tough (neither so easy :P) and all , u just
> need to think aloud
>
> 10 marks :
>
> 1. Find gcd of 2 numbers U & V in O(log UV)^2
>
> 2.   Test cases for finger print recognition say in a laptop to login
>
> 3. Design question..for billing , u have barcode, barcode number,
> item price, taxes, discounts for items (some criteria were given and u
> have to  design an algo for calculating discount) and then finally
> compute Net pricewhat DS u ll usehow ll u improve this
> design...State advantages and disadvantages.
>
> u have to think aloud and innovative ..thats it :)
>
> On Jul 18, 8:46 pm, Ankur Garg  wrote:
> > post on 22nd itself bro ;) ..there is a written  test on 23rd
> >
> > On Mon, Jul 18, 2011 at 8:45 PM, siva viknesh  >wrote:
> >
> >
> >
> >
> >
> >
> >
> > > @all..thanks a lotsure ll post the questions after 22nd :)
> >
> > > On Jul 18, 8:13 pm, sourabh jakhar  wrote:
> > > > study basic well they give a lot of emphasis on them
> >
> > > > On Mon, Jul 18, 2011 at 8:41 PM, SkRiPt KiDdIe <
> anuragmsi...@gmail.com
> > > >wrote:
> >
> > > > > After 22nd plz post ur questions ... !!
> > > > > It wud be of great HelP.
> >
> > > > > --
> > > > > 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.
> >
> > > > --
> > > > SOURABH JAKHAR,(CSE)(Final 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
> 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: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread svm11
Sorry it gt posted thrice.

On Jul 22, 7:50 pm, vaibhavmitta...@gmail.com wrote:
> https://ideone.com/kzo2L
>
> Regards
> Vaibhav Mittal
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.
>
> On , Pankaj  wrote:
>
>
>
>
>
>
>
> > Vaibhav, Ok write your code and paste on ideone. It should be easy and  
> > quick to code :)
> > On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com> wrote:
> > U hv got my algo completely wrong. Gimme a smaller test case so that i  
> > may wrk it out fr u. This one is freakingly large :P.
> > Regards
> > Vaibhav Mittal
> > Computer Science
> > Netaji Subhas Institute Of Technology
> > Delhi.
> > On , Pankaj jatka.oppimi...@gmail.com> wrote:
> > > abcdeaifjlbmnodpq
> > > For this once you encounter a at 6th position, You can update your  
> > max.Now You will have to do following operation.
> > > First clear all the hash.
> > > 2. You now can not start from 6th position. You will have to do back  
> > and start from 2 position that is b.
>
> > > Right?
> > > What is the maximum unique string in above test case?
> > > Try printing each sub string formed whenever you hit a duplicate.
> > > It's still O(N) though if we have constant number of characters :)
>
> > > On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com> wrote:
>
> > > Have a look again. I traverse the string just once performing updation  
> > on variables low, high, max. I assume array operations to be O(1) (which  
> > they are). OVerall complexity is O(n).Once I hit a duplicate i change my  
> > low, high and A accordingly and move forward.
>
> > > Regards
> > > Vaibhav Mittal
> > > Computer Science
> > > Netaji Subhas Institute Of Technology
> > > Delhi.
>
> > > On , Pankaj jatka.oppimi...@gmail.com> wrote:
>
> > > > VaibhavWhat do you think the complexity of your algo is. And once you  
> > hit an duplicate, from where will you start again?
> > > > Try for this example
> > > > abcdeaifjlbmnodpq.
> > > > It will be still O(26*n) as at max, we would have to start from each  
> > letter and go forward maximum 26times( if we reach 26 then we have it  
> > largest possible unique string). Otherwise keep checking.
>
> > > > So overall maximum complexity can be (MAX*n) where max will be unique  
> > letters.
> > > > Abhishek, I think the final complexity can never be O(n^2) if you  
> > only consider unique letters az.
> > > > The suggested soln is purely bruteforce. If anyone can think of a  
> > better solution then please reply.
>
> > > > Cheers
> > > > Pankaj
>
> > > > On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com>  
> > wrote:
>
> > > > VaibhavWhat do you thing the complexity of your algo is. And once you  
> > hit an duplicate, from where will you start again?
>
> > > > On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com> wrote:
>
> > > > String is "abcded"
> > > > l =0, h = 0
>
> > > > i = 1, l = 0, h = 1, max = 1, A[a]=1
> > > > i = 2, l = 0, h = 2, max = 2, A[b] = 2
>
> > > > i = 3, l = 0, h = 3, max = 3, A[c] = 3
> > > > i = 4, l = 0, h = 4, max = 4, A[d] = 4
>
> > > > i = 5, l = 0, h = 5, max = 5, A[e] = 5
> > > > i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h  
> > = 6, max = max(5, 6-4)= max(5, 2) = 5
>
> > > > hence ur ans = 5
>
> > > > Regards
> > > > Vaibhav Mittal
> > > > Computer Science
> > > > Netaji Subhas Institute Of Technology
> > > > Delhi.
>
> > > > On , Interstellar Overdrive abhi123khat...@gmail.com> wrote:
>
> > > > > @svm11: Take the case with original string "abcded" output should  
> > be 5 but your algo will give the answer as 0.
>
> > > > > --
>
> > > > > 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/-/hG6ZNcG5fMMJ.
>
> > > > > 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.
>
> > > --
>
> > > You received this message because you are s

[algogeeks] Re: MICROSOFT!!!!

2011-07-22 Thread siva viknesh
@ankur.. as u said i m posting today :) :)

10 questions c output, one compiler based(CFG) ,one OS
based (when reading internally it was just a simple percentage
calculation question)..

+3 for correct ans..
-2 for wrong ans...Damn it.. i dint notice d negative marking and
attended all :(

...questions were not so tough (neither so easy :P) and all , u just
need to think aloud

10 marks :

1. Find gcd of 2 numbers U & V in O(log UV)^2

2.   Test cases for finger print recognition say in a laptop to login

3. Design question..for billing , u have barcode, barcode number,
item price, taxes, discounts for items (some criteria were given and u
have to  design an algo for calculating discount) and then finally
compute Net pricewhat DS u ll usehow ll u improve this
design...State advantages and disadvantages.

u have to think aloud and innovative ..thats it :)

On Jul 18, 8:46 pm, Ankur Garg  wrote:
> post on 22nd itself bro ;) ..there is a written  test on 23rd
>
> On Mon, Jul 18, 2011 at 8:45 PM, siva viknesh wrote:
>
>
>
>
>
>
>
> > @all..thanks a lotsure ll post the questions after 22nd :)
>
> > On Jul 18, 8:13 pm, sourabh jakhar  wrote:
> > > study basic well they give a lot of emphasis on them
>
> > > On Mon, Jul 18, 2011 at 8:41 PM, SkRiPt KiDdIe  > >wrote:
>
> > > > After 22nd plz post ur questions ... !!
> > > > It wud be of great HelP.
>
> > > > --
> > > > 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.
>
> > > --
> > > SOURABH JAKHAR,(CSE)(Final 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 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] Printf evaluation

2011-07-22 Thread shady
so many times such questions have come... behavior is entirely compiler
dependent
if you are preparing for interviews then believe me no one in the whole
world will ask such questions to you. there's no point discussing it

On Fri, Jul 22, 2011 at 8:15 PM, Gaurav Popli  wrote:

> may be im wrongbut i read it somewhere about it...the arguments of
> a function are evaluated in a associativity that is compiler
> dependent...
>
> for ex...
>
> printf("%d  %d  %d" ,fun1(),fun2(),fun3());
> the order in which functions are evaluated are compiler dependent
>
> On Fri, Jul 22, 2011 at 7:20 PM, Abhinav Verma
>  wrote:
> > Its not the associativity which is undefined (Associativity has been
> defined
> > clearly by the C Standards for each and every operator). Its the order of
> > evaluation between 2 sequence points which is undefined and hence
> > compiler-dependent.
> > On gcc version 4.4.3, output generated is 5551. On some other compiler,
> the
> > output may differ.
> >
> > On Fri, Jul 22, 2011 at 6:09 PM, Gaurav Popli 
> wrote:
> >>
> >> associativity rule is compiler dependent ...thats why undefined...
> >>
> >> On Fri, Jul 22, 2011 at 5:46 PM, Kamakshii Aggarwal
> >>  wrote:
> >> > undefined behaviour.
> >> > since value of i is changing more than once between two sequence
> >> > points..
> >> > On Fri, Jul 22, 2011 at 5:42 PM, suresh srinivasan <
> suree...@gmail.com>
> >> > wrote:
> >> >>
> >> >> Output:
> >> >> 5,4,3,1
> >> >>
> >> >> Explanation:
> >> >> Since the brackets acts as right precedence, the execution of the
> >> >> statement is from right to left. The comma separates the individual.
> >> >> For i++, it prints the current 'i' value and increments it by 1.
> >> >> For ++i, it increments the value by 1 and prints the updated value of
> >> >> 'i'.
> >> >> --
> >> >> Regards,
> >> >> Suresh.S
> >> >>
> >> >> --
> >> >> 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,
> >> > Kamakshi
> >> > kamakshi...@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.
> >> >
> >>
> >> --
> >> 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.
>
>

-- 
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: Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11

https://ideone.com/kzo2L

Regards
Vaibhav Mittal
Computer Science
Netaji Subhas Institute Of Technology
Delhi.

On , Pankaj  wrote:
Vaibhav, Ok write your code and paste on ideone. It should be easy and  
quick to code :)




On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com> wrote:



U hv got my algo completely wrong. Gimme a smaller test case so that i  
may wrk it out fr u. This one is freakingly large :P.






Regards
Vaibhav Mittal
Computer Science
Netaji Subhas Institute Of Technology
Delhi.



On , Pankaj jatka.oppimi...@gmail.com> wrote:




> abcdeaifjlbmnodpq
> For this once you encounter a at 6th position, You can update your  
max.Now You will have to do following operation.

> First clear all the hash.
> 2. You now can not start from 6th position. You will have to do back  
and start from 2 position that is b.




>
>
>
>
> Right?
> What is the maximum unique string in above test case?
> Try printing each sub string formed whenever you hit a duplicate.
> It's still O(N) though if we have constant number of characters :)




>
>
>
>
> On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com> wrote:
>
>
> Have a look again. I traverse the string just once performing updation  
on variables low, high, max. I assume array operations to be O(1) (which  
they are). OVerall complexity is O(n).Once I hit a duplicate i change my  
low, high and A accordingly and move forward.




>
>
>
> Regards
> Vaibhav Mittal
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.
>
>
> On , Pankaj jatka.oppimi...@gmail.com> wrote:




>
>
> > VaibhavWhat do you think the complexity of your algo is. And once you  
hit an duplicate, from where will you start again?

> > Try for this example
> > abcdeaifjlbmnodpq.
> > It will be still O(26*n) as at max, we would have to start from each  
letter and go forward maximum 26times( if we reach 26 then we have it  
largest possible unique string). Otherwise keep checking.




>
>
> >
> >
> > So overall maximum complexity can be (MAX*n) where max will be unique  
letters.
> > Abhishek, I think the final complexity can never be O(n^2) if you  
only consider unique letters az.



> > The suggested soln is purely bruteforce. If anyone can think of a  
better solution then please reply.

>
>
> >
> >
> >
> >
> > Cheers
> > Pankaj




> >
> > On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com>  
wrote:

>
>
> >
> >
> >




>
> > VaibhavWhat do you thing the complexity of your algo is. And once you  
hit an duplicate, from where will you start again?

>
> >
> >
> >
>
>
> >




> >
> > On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com> wrote:
> >
> >
> > String is "abcded"




> > l =0, h = 0
>
>
> > i = 1, l = 0, h = 1, max = 1, A[a]=1
> > i = 2, l = 0, h = 2, max = 2, A[b] = 2
> >
> >
> >
> >
> > i = 3, l = 0, h = 3, max = 3, A[c] = 3




> > i = 4, l = 0, h = 4, max = 4, A[d] = 4
>
>
> > i = 5, l = 0, h = 5, max = 5, A[e] = 5
> > i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h  
= 6, max = max(5, 6-4)= max(5, 2) = 5




> >
> >
> >
> >
> >
> > hence ur ans = 5
>
>
> >
> > Regards
> > Vaibhav Mittal
> > Computer Science
> > Netaji Subhas Institute Of Technology




> > Delhi.
> >
> >
> > On , Interstellar Overdrive abhi123khat...@gmail.com> wrote:
>
>
> >
> >




> >
> >
> > > @svm11: Take the case with original string "abcded" output should  
be 5 but your algo will give the answer as 0.

> > >
> > >
> > >




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




>
>
> > >
> > > 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/a

Re: Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11

https://ideone.com/kzo2L

Regards
Vaibhav Mittal
Computer Science
Netaji Subhas Institute Of Technology
Delhi.

On , Pankaj  wrote:
Vaibhav, Ok write your code and paste on ideone. It should be easy and  
quick to code :)




On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com> wrote:



U hv got my algo completely wrong. Gimme a smaller test case so that i  
may wrk it out fr u. This one is freakingly large :P.






Regards
Vaibhav Mittal
Computer Science
Netaji Subhas Institute Of Technology
Delhi.



On , Pankaj jatka.oppimi...@gmail.com> wrote:




> abcdeaifjlbmnodpq
> For this once you encounter a at 6th position, You can update your  
max.Now You will have to do following operation.

> First clear all the hash.
> 2. You now can not start from 6th position. You will have to do back  
and start from 2 position that is b.




>
>
>
>
> Right?
> What is the maximum unique string in above test case?
> Try printing each sub string formed whenever you hit a duplicate.
> It's still O(N) though if we have constant number of characters :)




>
>
>
>
> On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com> wrote:
>
>
> Have a look again. I traverse the string just once performing updation  
on variables low, high, max. I assume array operations to be O(1) (which  
they are). OVerall complexity is O(n).Once I hit a duplicate i change my  
low, high and A accordingly and move forward.




>
>
>
> Regards
> Vaibhav Mittal
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.
>
>
> On , Pankaj jatka.oppimi...@gmail.com> wrote:




>
>
> > VaibhavWhat do you think the complexity of your algo is. And once you  
hit an duplicate, from where will you start again?

> > Try for this example
> > abcdeaifjlbmnodpq.
> > It will be still O(26*n) as at max, we would have to start from each  
letter and go forward maximum 26times( if we reach 26 then we have it  
largest possible unique string). Otherwise keep checking.




>
>
> >
> >
> > So overall maximum complexity can be (MAX*n) where max will be unique  
letters.
> > Abhishek, I think the final complexity can never be O(n^2) if you  
only consider unique letters az.



> > The suggested soln is purely bruteforce. If anyone can think of a  
better solution then please reply.

>
>
> >
> >
> >
> >
> > Cheers
> > Pankaj




> >
> > On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com>  
wrote:

>
>
> >
> >
> >




>
> > VaibhavWhat do you thing the complexity of your algo is. And once you  
hit an duplicate, from where will you start again?

>
> >
> >
> >
>
>
> >




> >
> > On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com> wrote:
> >
> >
> > String is "abcded"




> > l =0, h = 0
>
>
> > i = 1, l = 0, h = 1, max = 1, A[a]=1
> > i = 2, l = 0, h = 2, max = 2, A[b] = 2
> >
> >
> >
> >
> > i = 3, l = 0, h = 3, max = 3, A[c] = 3




> > i = 4, l = 0, h = 4, max = 4, A[d] = 4
>
>
> > i = 5, l = 0, h = 5, max = 5, A[e] = 5
> > i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h  
= 6, max = max(5, 6-4)= max(5, 2) = 5




> >
> >
> >
> >
> >
> > hence ur ans = 5
>
>
> >
> > Regards
> > Vaibhav Mittal
> > Computer Science
> > Netaji Subhas Institute Of Technology




> > Delhi.
> >
> >
> > On , Interstellar Overdrive abhi123khat...@gmail.com> wrote:
>
>
> >
> >




> >
> >
> > > @svm11: Take the case with original string "abcded" output should  
be 5 but your algo will give the answer as 0.

> > >
> > >
> > >




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




>
>
> > >
> > > 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/a

Re: Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11

https://ideone.com/kzo2L

Regards
Vaibhav Mittal
Computer Science
Netaji Subhas Institute Of Technology
Delhi.

On , Pankaj  wrote:
Vaibhav, Ok write your code and paste on ideone. It should be easy and  
quick to code :)




On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com> wrote:



U hv got my algo completely wrong. Gimme a smaller test case so that i  
may wrk it out fr u. This one is freakingly large :P.






Regards
Vaibhav Mittal
Computer Science
Netaji Subhas Institute Of Technology
Delhi.



On , Pankaj jatka.oppimi...@gmail.com> wrote:




> abcdeaifjlbmnodpq
> For this once you encounter a at 6th position, You can update your  
max.Now You will have to do following operation.

> First clear all the hash.
> 2. You now can not start from 6th position. You will have to do back  
and start from 2 position that is b.




>
>
>
>
> Right?
> What is the maximum unique string in above test case?
> Try printing each sub string formed whenever you hit a duplicate.
> It's still O(N) though if we have constant number of characters :)




>
>
>
>
> On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com> wrote:
>
>
> Have a look again. I traverse the string just once performing updation  
on variables low, high, max. I assume array operations to be O(1) (which  
they are). OVerall complexity is O(n).Once I hit a duplicate i change my  
low, high and A accordingly and move forward.




>
>
>
> Regards
> Vaibhav Mittal
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.
>
>
> On , Pankaj jatka.oppimi...@gmail.com> wrote:




>
>
> > VaibhavWhat do you think the complexity of your algo is. And once you  
hit an duplicate, from where will you start again?

> > Try for this example
> > abcdeaifjlbmnodpq.
> > It will be still O(26*n) as at max, we would have to start from each  
letter and go forward maximum 26times( if we reach 26 then we have it  
largest possible unique string). Otherwise keep checking.




>
>
> >
> >
> > So overall maximum complexity can be (MAX*n) where max will be unique  
letters.
> > Abhishek, I think the final complexity can never be O(n^2) if you  
only consider unique letters az.



> > The suggested soln is purely bruteforce. If anyone can think of a  
better solution then please reply.

>
>
> >
> >
> >
> >
> > Cheers
> > Pankaj




> >
> > On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com>  
wrote:

>
>
> >
> >
> >




>
> > VaibhavWhat do you thing the complexity of your algo is. And once you  
hit an duplicate, from where will you start again?

>
> >
> >
> >
>
>
> >




> >
> > On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com> wrote:
> >
> >
> > String is "abcded"




> > l =0, h = 0
>
>
> > i = 1, l = 0, h = 1, max = 1, A[a]=1
> > i = 2, l = 0, h = 2, max = 2, A[b] = 2
> >
> >
> >
> >
> > i = 3, l = 0, h = 3, max = 3, A[c] = 3




> > i = 4, l = 0, h = 4, max = 4, A[d] = 4
>
>
> > i = 5, l = 0, h = 5, max = 5, A[e] = 5
> > i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h  
= 6, max = max(5, 6-4)= max(5, 2) = 5




> >
> >
> >
> >
> >
> > hence ur ans = 5
>
>
> >
> > Regards
> > Vaibhav Mittal
> > Computer Science
> > Netaji Subhas Institute Of Technology




> > Delhi.
> >
> >
> > On , Interstellar Overdrive abhi123khat...@gmail.com> wrote:
>
>
> >
> >




> >
> >
> > > @svm11: Take the case with original string "abcded" output should  
be 5 but your algo will give the answer as 0.

> > >
> > >
> > >




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




>
>
> > >
> > > 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/a

Re: [algogeeks] Printf evaluation

2011-07-22 Thread Gaurav Popli
may be im wrongbut i read it somewhere about it...the arguments of
a function are evaluated in a associativity that is compiler
dependent...

for ex...

printf("%d  %d  %d" ,fun1(),fun2(),fun3());
the order in which functions are evaluated are compiler dependent

On Fri, Jul 22, 2011 at 7:20 PM, Abhinav Verma
 wrote:
> Its not the associativity which is undefined (Associativity has been defined
> clearly by the C Standards for each and every operator). Its the order of
> evaluation between 2 sequence points which is undefined and hence
> compiler-dependent.
> On gcc version 4.4.3, output generated is 5551. On some other compiler, the
> output may differ.
>
> On Fri, Jul 22, 2011 at 6:09 PM, Gaurav Popli  wrote:
>>
>> associativity rule is compiler dependent ...thats why undefined...
>>
>> On Fri, Jul 22, 2011 at 5:46 PM, Kamakshii Aggarwal
>>  wrote:
>> > undefined behaviour.
>> > since value of i is changing more than once between two sequence
>> > points..
>> > On Fri, Jul 22, 2011 at 5:42 PM, suresh srinivasan 
>> > wrote:
>> >>
>> >> Output:
>> >> 5,4,3,1
>> >>
>> >> Explanation:
>> >> Since the brackets acts as right precedence, the execution of the
>> >> statement is from right to left. The comma separates the individual.
>> >> For i++, it prints the current 'i' value and increments it by 1.
>> >> For ++i, it increments the value by 1 and prints the updated value of
>> >> 'i'.
>> >> --
>> >> Regards,
>> >> Suresh.S
>> >>
>> >> --
>> >> 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,
>> > Kamakshi
>> > kamakshi...@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.
>> >
>>
>> --
>> 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] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Pankaj
Chetan,

No. How could you relate this problem with that? Do you find something
similar?

~
Pankaj

On Fri, Jul 22, 2011 at 8:01 PM, chetan kapoor wrote:

> josehus problem???
>
>
> On Fri, Jul 22, 2011 at 7:57 PM, Pankaj  wrote:
>
>> Skipp Riddle,
>> Yes.
>> 100th prisoner will risk his life. Similar puzzle was discuss recently.
>> Does anyone remember the name or thread?
>>
>>
>> ~
>> Pankaj
>>
>>
>> On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe wrote:
>>
>>> Worst case 99 get released.
>>> Is that correct..?
>>>
>>>  --
>>> 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.
>

-- 
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: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Pankaj
Vaibhav,
Ok write your code and paste on ideone. It should be easy and quick to code
:)


On Fri, Jul 22, 2011 at 7:59 PM,  wrote:

> U hv got my algo completely wrong. Gimme a smaller test case so that i may
> wrk it out fr u. This one is freakingly large :P.
>
>
> Regards
> Vaibhav Mittal
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.
>
> On , Pankaj  wrote:
> > abcdeaifjlbmnodpq
> > For this once you encounter a at 6th position, You can update your
> max.Now You will have to do following operation.
> > First clear all the hash.
> > 2. You now can not start from 6th position. You will have to do back and
> start from 2 position that is b.
> >
> >
> >
> >
> > Right?
> > What is the maximum unique string in above test case?
> > Try printing each sub string formed whenever you hit a duplicate.
> > It's still O(N) though if we have constant number of characters :)
> >
> >
> >
> >
> > On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com> wrote:
> >
> >
> > Have a look again. I traverse the string just once performing updation on
> variables low, high, max. I assume array operations to be O(1) (which they
> are). OVerall complexity is O(n).Once I hit a duplicate i change my low,
> high and A accordingly and move forward.
> >
> >
> >
> > Regards
> > Vaibhav Mittal
> > Computer Science
> > Netaji Subhas Institute Of Technology
> > Delhi.
> >
> >
> > On , Pankaj jatka.oppimi...@gmail.com> wrote:
> >
> >
> > > VaibhavWhat do you think the complexity of your algo is. And once you
> hit an duplicate, from where will you start again?
> > > Try for this example
> > > abcdeaifjlbmnodpq.
> > > It will be still O(26*n) as at max, we would have to start from each
> letter and go forward maximum 26times( if we reach 26 then we have it
> largest possible unique string). Otherwise keep checking.
> >
> >
> > >
> > >
> > > So overall maximum complexity can be (MAX*n) where max will be unique
> letters.
> > > Abhishek, I think the final complexity can never be O(n^2) if you only
> consider unique letters a-z.
> > > The suggested soln is purely bruteforce. If anyone can think of a
> better solution then please reply.
> >
> >
> > >
> > >
> > >
> > >
> > > Cheers
> > > Pankaj
> > >
> > > On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com>
> wrote:
> >
> >
> > >
> > >
> > >
> >
> > > VaibhavWhat do you thing the complexity of your algo is. And once you
> hit an duplicate, from where will you start again?
> >
> > >
> > >
> > >
> >
> >
> > >
> > >
> > > On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com> wrote:
> > >
> > >
> > > String is "abcded"
> > > l =0, h = 0
> >
> >
> > > i = 1, l = 0, h = 1, max = 1, A[a]=1
> > > i = 2, l = 0, h = 2, max = 2, A[b] = 2
> > >
> > >
> > >
> > >
> > > i = 3, l = 0, h = 3, max = 3, A[c] = 3
> > > i = 4, l = 0, h = 4, max = 4, A[d] = 4
> >
> >
> > > i = 5, l = 0, h = 5, max = 5, A[e] = 5
> > > i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h =
> 6, max = max(5, 6-4)= max(5, 2) = 5
> > >
> > >
> > >
> > >
> > >
> > > hence ur ans = 5
> >
> >
> > >
> > > Regards
> > > Vaibhav Mittal
> > > Computer Science
> > > Netaji Subhas Institute Of Technology
> > > Delhi.
> > >
> > >
> > > On , Interstellar Overdrive abhi123khat...@gmail.com> wrote:
> >
> >
> > >
> > >
> > >
> > >
> > > > @svm11: Take the case with original string "abcded" output should be
> 5 but your algo will give the answer as 0.
> > > >
> > > >
> > > >
> > > >
> >
> >
> > > > --
> > > >
> > > > 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/-/hG6ZNcG5fMMJ.
> >
> >
> > > >
> > > > 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...@googlegroup

Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread chetan kapoor
josehus problem???

On Fri, Jul 22, 2011 at 7:57 PM, Pankaj  wrote:

> Skipp Riddle,
> Yes.
> 100th prisoner will risk his life. Similar puzzle was discuss recently.
> Does anyone remember the name or thread?
>
>
> ~
> Pankaj
>
>
> On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe wrote:
>
>> Worst case 99 get released.
>> Is that correct..?
>>
>>  --
>> 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: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Pankaj
*abcdea*ifjlbmnodpq
For this once you encounter a at 6th position, You can update your max.
Now You will have to do following operation.
First clear all the hash.
2. You now can not start from 6th position. You will have to do back and
start from 2 position that is b.

Right?
What is the maximum unique string in above test case?
Try printing each sub string formed whenever you hit a duplicate.
It's still O(N) though if we have constant number of characters :)

On Fri, Jul 22, 2011 at 7:50 PM,  wrote:

> Have a look again. I traverse the string just once performing updation on
> variables low, high, max. I assume array operations to be O(1) (which they
> are). OVerall complexity is O(n).Once I hit a duplicate i change my low,
> high and A accordingly and move forward.
>
>
> Regards
> Vaibhav Mittal
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.
>
> On , Pankaj  wrote:
> > VaibhavWhat do you think the complexity of your algo is. And once you hit
> an duplicate, from where will you start again?
>
> > Try for this example
> > abcdeaifjlbmnodpq.
> > It will be still O(26*n) as at max, we would have to start from each
> letter and go forward maximum 26times( if we reach 26 then we have it
> largest possible unique string). Otherwise keep checking.
> >
> >
> > So overall maximum complexity can be (MAX*n) where max will be unique
> letters.
> > Abhishek, I think the final complexity can never be O(n^2) if you only
> consider unique letters a-z.
> > The suggested soln is purely bruteforce. If anyone can think of a better
> solution then please reply.
> >
> >
> >
> >
> > Cheers
> > Pankaj
> >
> > On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com>
> wrote:
> >
> >
> >
> > VaibhavWhat do you thing the complexity of your algo is. And once you hit
> an duplicate, from where will you start again?
>
> >
> >
> >
> >
> >
> > On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com> wrote:
> >
> >
> > String is "abcded"
> > l =0, h = 0
> > i = 1, l = 0, h = 1, max = 1, A[a]=1
> > i = 2, l = 0, h = 2, max = 2, A[b] = 2
> >
> >
> >
> >
> > i = 3, l = 0, h = 3, max = 3, A[c] = 3
> > i = 4, l = 0, h = 4, max = 4, A[d] = 4
> > i = 5, l = 0, h = 5, max = 5, A[e] = 5
> > i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h =
> 6, max = max(5, 6-4)= max(5, 2) = 5
> >
> >
> >
> >
> >
> > hence ur ans = 5
> >
> > Regards
> > Vaibhav Mittal
> > Computer Science
> > Netaji Subhas Institute Of Technology
> > Delhi.
> >
> >
> > On , Interstellar Overdrive abhi123khat...@gmail.com> wrote:
> >
> >
> >
> >
> > > @svm11: Take the case with original string "abcded" output should be 5
> but your algo will give the answer as 0.
> > >
> > >
> > >
> > >
> > > --
> > >
> > > 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/-/hG6ZNcG5fMMJ.
> > >
> > > 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.
> >
> >
> >
> >
>
> --
> 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: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
U hv got my algo completely wrong. Gimme a smaller test case so that i may  
wrk it out fr u. This one is freakingly large :P.


Regards
Vaibhav Mittal
Computer Science
Netaji Subhas Institute Of Technology
Delhi.

On , Pankaj  wrote:

abcdeaifjlbmnodpq
For this once you encounter a at 6th position, You can update your  
max.Now You will have to do following operation.

First clear all the hash.
2. You now can not start from 6th position. You will have to do back and  
start from 2 position that is b.






Right?
What is the maximum unique string in above test case?
Try printing each sub string formed whenever you hit a duplicate.
It's still O(N) though if we have constant number of characters :)






On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com> wrote:



Have a look again. I traverse the string just once performing updation on  
variables low, high, max. I assume array operations to be O(1) (which  
they are). OVerall complexity is O(n).Once I hit a duplicate i change my  
low, high and A accordingly and move forward.





Regards
Vaibhav Mittal
Computer Science
Netaji Subhas Institute Of Technology
Delhi.




On , Pankaj jatka.oppimi...@gmail.com> wrote:



> VaibhavWhat do you think the complexity of your algo is. And once you  
hit an duplicate, from where will you start again?

> Try for this example
> abcdeaifjlbmnodpq.
> It will be still O(26*n) as at max, we would have to start from each  
letter and go forward maximum 26times( if we reach 26 then we have it  
largest possible unique string). Otherwise keep checking.




>
>
> So overall maximum complexity can be (MAX*n) where max will be unique  
letters.
> Abhishek, I think the final complexity can never be O(n^2) if you only  
consider unique letters az.
> The suggested soln is purely bruteforce. If anyone can think of a  
better solution then please reply.




>
>
>
>
> Cheers
> Pankaj
>
> On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com>  
wrote:




>
>
>


> VaibhavWhat do you thing the complexity of your algo is. And once you  
hit an duplicate, from where will you start again?



>
>
>




>
>
> On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com> wrote:
>
>
> String is "abcded"
> l =0, h = 0




> i = 1, l = 0, h = 1, max = 1, A[a]=1
> i = 2, l = 0, h = 2, max = 2, A[b] = 2
>
>
>
>
> i = 3, l = 0, h = 3, max = 3, A[c] = 3
> i = 4, l = 0, h = 4, max = 4, A[d] = 4




> i = 5, l = 0, h = 5, max = 5, A[e] = 5
> i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h =  
6, max = max(5, 6-4)= max(5, 2) = 5

>
>
>
>
>
> hence ur ans = 5




>
> Regards
> Vaibhav Mittal
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.
>
>
> On , Interstellar Overdrive abhi123khat...@gmail.com> wrote:




>
>
>
>
> > @svm11: Take the case with original string "abcded" output should be  
5 but your algo will give the answer as 0.

> >
> >
> >
> >




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




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

>
>
>
>






--


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=

Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Pankaj
Skipp Riddle,
Yes.
100th prisoner will risk his life. Similar puzzle was discuss recently. Does
anyone remember the name or thread?


~
Pankaj

On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe wrote:

> Worst case 99 get released.
> Is that correct..?
>
>  --
> 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] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread SkRiPt KiDdIe
Worst case 99 get released.
Is that correct..?

-- 
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: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
Have a look again. I traverse the string just once performing updation on  
variables low, high, max. I assume array operations to be O(1) (which they  
are). OVerall complexity is O(n).Once I hit a duplicate i change my low,  
high and A accordingly and move forward.


Regards
Vaibhav Mittal
Computer Science
Netaji Subhas Institute Of Technology
Delhi.

On , Pankaj  wrote:
VaibhavWhat do you think the complexity of your algo is. And once you hit  
an duplicate, from where will you start again?

Try for this example
abcdeaifjlbmnodpq.
It will be still O(26*n) as at max, we would have to start from each  
letter and go forward maximum 26times( if we reach 26 then we have it  
largest possible unique string). Otherwise keep checking.



So overall maximum complexity can be (MAX*n) where max will be unique  
letters.
Abhishek, I think the final complexity can never be O(n^2) if you only  
consider unique letters az.
The suggested soln is purely bruteforce. If anyone can think of a better  
solution then please reply.






Cheers
Pankaj



On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com> wrote:




VaibhavWhat do you thing the complexity of your algo is. And once you hit  
an duplicate, from where will you start again?







On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com> wrote:




String is "abcded"
l =0, h = 0
i = 1, l = 0, h = 1, max = 1, A[a]=1
i = 2, l = 0, h = 2, max = 2, A[b] = 2






i = 3, l = 0, h = 3, max = 3, A[c] = 3
i = 4, l = 0, h = 4, max = 4, A[d] = 4
i = 5, l = 0, h = 5, max = 5, A[e] = 5
i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h =  
6, max = max(5, 6-4)= max(5, 2) = 5







hence ur ans = 5



Regards
Vaibhav Mittal
Computer Science
Netaji Subhas Institute Of Technology
Delhi.




On , Interstellar Overdrive abhi123khat...@gmail.com> wrote:





> @svm11: Take the case with original string "abcded" output should be 5  
but your algo will give the answer as 0.

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

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





--
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] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Pankaj
In my latest interview I encountered the following puzzle.

There are 100 prisoners in the prison. All of them have either black or
white cap.

Jailer has asked them to stand in the queue such that nth guy can see caps
of all the guys standing ahead of him, but he can not see his own cap.

It means Guy standing at 100th position can see caps of all other 99 guys.
Prisoner standing at 99th position can see caps of rest of 98 guys standing
ahead of him.

Now jailer proposes to release the guy who can guess correct color of his
own cap.

Assuming All the prisoner are nice guys ;), who can sacrifice for others,
device a method which can help to release maximum number of prisoners.

On Fri, Jul 22, 2011 at 7:46 PM, Vishal Jain  wrote:

> Hi All,
>
> In my last interview(given few months back), I was asked the following
> puzzle..
>
> http://goo.gl/jrnpc
>
> Could you please tell me the solution for the same?
>
> Thanks & Regards
> Vishal Jain
> MNo: +91-9540611889
> Tweet @jainvis
> Blog @ jainvish.blogspot.com
> Success taste better when target achieved is bigger.
>
> P *We have a responsibility to the environment.*
>
> *Before printing this e-mail or any other document, let's ask ourselves 
> whether we need a hard copy.*
>
>
>  --
> 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] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Vishal Jain
Hi All,

In my last interview(given few months back), I was asked the following
puzzle..

http://goo.gl/jrnpc

Could you please tell me the solution for the same?

Thanks & Regards
Vishal Jain
MNo: +91-9540611889
Tweet @jainvis
Blog @ jainvish.blogspot.com
Success taste better when target achieved is bigger.

P *We have a responsibility to the environment.*

*Before printing this e-mail or any other document, let's ask
ourselves whether we need a hard copy.*

-- 
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: Shooters in a circle

2011-07-22 Thread surender sanke
@kunal patil ur right, i forgot to mention k=2.
refer http://www.exploringbinary.com/powers-of-two-in-the-josephus-problem/

surender


On Fri, Jul 22, 2011 at 7:21 PM, Kunal Patil  wrote:

> @surender: I assume you want to give general solution to Josephus problem
> in which we shoot every kth person...In that case formula for pos must be:
> pos = ( x*k )%n + (k-1)
>
> In current context, k=2...thus the formula which you gave also holds
> true..but not when k != 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.
>

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



Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Pankaj
Vaibhav
What do you think the complexity of your algo is. And once you hit an
duplicate, from where will you start again?
Try for this example
abcdeaifjlbmnodpq.
It will be still O(26*n) as at max, we would have to start from each letter
and go forward maximum 26times( if we reach 26 then we have it largest
possible unique string). Otherwise keep checking.
So overall maximum complexity can be (MAX*n) where max will be unique
letters.
Abhishek, I think the final complexity can never be O(n^2) if you only
consider unique letters a-z.
The suggested soln is purely bruteforce. If anyone can think of a better
solution then please reply.

Cheers
Pankaj

On Fri, Jul 22, 2011 at 7:37 PM, Pankaj  wrote:

> Vaibhav
> What do you thing the complexity of your algo is. And once you hit an
> duplicate, from where will you start again?
>
> On Fri, Jul 22, 2011 at 7:21 PM,  wrote:
>
>> String is "abcded"
>> l =0, h = 0
>> i = 1, l = 0, h = 1, max = 1, A[a]=1
>> i = 2, l = 0, h = 2, max = 2, A[b] = 2
>> i = 3, l = 0, h = 3, max = 3, A[c] = 3
>> i = 4, l = 0, h = 4, max = 4, A[d] = 4
>> i = 5, l = 0, h = 5, max = 5, A[e] = 5
>> i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6,
>> max = max(5, 6-4)= max(5, 2) = 5
>>
>> hence ur ans = 5
>>
>>
>> Regards
>> Vaibhav Mittal
>> Computer Science
>> Netaji Subhas Institute Of Technology
>> Delhi.
>> On , Interstellar Overdrive  wrote:
>> > @svm11: Take the case with original string "abcded" output should be 5
>> but your algo will give the answer as 0.
>> >
>> >
>> >
>> >
>> > --
>> >
>> > 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/-/hG6ZNcG5fMMJ.
>> >
>> > 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] Re: Largest substring with unique characters

2011-07-22 Thread Pankaj
Vaibhav
What do you thing the complexity of your algo is. And once you hit an
duplicate, from where will you start again?

On Fri, Jul 22, 2011 at 7:21 PM,  wrote:

> String is "abcded"
> l =0, h = 0
> i = 1, l = 0, h = 1, max = 1, A[a]=1
> i = 2, l = 0, h = 2, max = 2, A[b] = 2
> i = 3, l = 0, h = 3, max = 3, A[c] = 3
> i = 4, l = 0, h = 4, max = 4, A[d] = 4
> i = 5, l = 0, h = 5, max = 5, A[e] = 5
> i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6,
> max = max(5, 6-4)= max(5, 2) = 5
>
> hence ur ans = 5
>
>
> Regards
> Vaibhav Mittal
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.
> On , Interstellar Overdrive  wrote:
> > @svm11: Take the case with original string "abcded" output should be 5
> but your algo will give the answer as 0.
> >
> >
> >
> >
> > --
> >
> > 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/-/hG6ZNcG5fMMJ.
> >
> > 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.



  1   2   >