Re: [algogeeks] logic error:

2011-06-06 Thread Logic King
How can you assume that team name cannot be other than these.where in
the question is written that only these teams will constitute the last 16.

i hope you got my point and your mistake as well !!

On Mon, Jun 6, 2011 at 4:28 AM, PRAMENDRA RATHi rathi
wrote:

>
> no, i am getting wrong answer again with this logic..
>
> it is my code::
>
> int main()
> {
> register int test,i,j,winner=0,g1,g2;
> string s1,s2;
> string
> team[16]={"ARG","BEL","BRZ","CAM","COL","CRC","CZE","ENG","GER","IRE","ITA","NET","ROM","SPA","URU","YUG"};
>
> cin >>test;
> while(test--)
> {
> int point[16]={0};
> for(j=0;j<16;j++)
> {
> cin>>s1>>s2>>g1>>g2;
> if(g1>g2)
> {
> for(i=0;i<16;i++)
> {
> if(s1==team[i])
> {point[i]++;break;}
> }
> }
> else
> {
> for(i=0;i<16;i++)
> {
> if(s2==team[i])
> {point[i]++;break;}
> }
> }
>
> }
> int big=0;
> for(i=0;i<16;i++)
>
> { cout<<"team "< if(point[i]==4){cout<
> }
>
> return 0;
>
> }
>
>
> On Mon, Jun 6, 2011 at 1:49 PM, nicks  wrote:
>
>> @parmendra..yeah u r right what's ur problem u r not able to implement it
>> r whatonly winner will win 4 matches runner and 3rd posn will win 3
>> match each...
>>
>>
>> On Mon, Jun 6, 2011 at 12:47 AM, arun kumar  wrote:
>>
>>> any team which has nt lost a match will win
>>>
>>> On Mon, Jun 6, 2011 at 1:12 PM, PRAMENDRA RATHi rathi
>>>  wrote:
>>> > i am thinking that the team with win point 4 will be the winner ..
>>> > is this wrong?
>>> >
>>> > https://www.spoj.pl/problems/SBETS/
>>> >
>>> >
>>> > because there are only 16 match 8+4+2+1(final) +1(for  runner up)
>>> > so any team can play at max 4 match.
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "Algorithm Geeks" group.
>>> > To post to this group, send email to algogeeks@googlegroups.com.
>>> > To unsubscribe from 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] MS Question

2011-06-02 Thread Logic King
hmm...then skip list is surely a better option

On Thu, Jun 2, 2011 at 7:04 AM, Ashish Goel  wrote:

> the problem here is what if more than 1 pointers are corrupt?
>
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
>
> On Thu, Jun 2, 2011 at 6:35 PM, Logic King wrote:
>
>> I Think circular DLL should do...skip list is not required !!
>>
>>
>> On Thu, Jun 2, 2011 at 5:31 AM, Ashish Goel  wrote:
>>
>>> wouldn't it be skip list or a circular DLL
>>>
>>> what if we have next as well as next->next pointers in every node. If the
>>> LL is say a->b>c>d
>>> if a->b is corrupted, a->c can be used to reach rest of the LL
>>> if say b->c is corrupt,
>>> a->c can be used to recover complete list...
>>>
>>>
>>> is this better or skip list?
>>>
>>>
>>> Best Regards
>>> Ashish Goel
>>> "Think positive and find fuel in failure"
>>> +919985813081
>>> +919966006652
>>>
>>>
>>> On Thu, Jun 2, 2011 at 9:39 AM, Kunal Patil  wrote:
>>>
>>>> @Gaurav: You might want to say circular doubly linked list, didn't you ?
>>>> coz without that, its not possible to reach last node if we are at first
>>>> node or vice-versa.
>>>>
>>>>
>>>> On Thu, Jun 2, 2011 at 9:31 AM, Gaurav Aggarwal 
>>>> <0007gau...@gmail.com>wrote:
>>>>
>>>>> other solution might be to use doubly linked list, even if one pointer
>>>>> gets corrupt, there is other path to reach the destination.
>>>>>
>>>>>
>>>>> On Wed, Jun 1, 2011 at 1:24 PM, Ashish Goel  wrote:
>>>>>
>>>>>> given a single linked list, there is a possibility of pointer
>>>>>> corruption, modify the data structure to ensure that the data is not 
>>>>>> lost.
>>>>>>
>>>>>> in my view a skip list is a good option, any other solutions?
>>>>>>
>>>>>> Best Regards
>>>>>> Ashish Goel
>>>>>> "Think positive and find fuel in failure"
>>>>>> +919985813081
>>>>>> +919966006652
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Algorithm Geeks" group.
>>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>>> To unsubscribe from this group, send email to
>>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Gaurav Aggarwal
>>>>> SCJP
>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] MS Question

2011-06-02 Thread Logic King
I Think circular DLL should do...skip list is not required !!

On Thu, Jun 2, 2011 at 5:31 AM, Ashish Goel  wrote:

> wouldn't it be skip list or a circular DLL
>
> what if we have next as well as next->next pointers in every node. If the
> LL is say a->b>c>d
> if a->b is corrupted, a->c can be used to reach rest of the LL
> if say b->c is corrupt,
> a->c can be used to recover complete list...
>
>
> is this better or skip list?
>
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
>
> On Thu, Jun 2, 2011 at 9:39 AM, Kunal Patil  wrote:
>
>> @Gaurav: You might want to say circular doubly linked list, didn't you ?
>> coz without that, its not possible to reach last node if we are at first
>> node or vice-versa.
>>
>>
>> On Thu, Jun 2, 2011 at 9:31 AM, Gaurav Aggarwal <0007gau...@gmail.com>wrote:
>>
>>> other solution might be to use doubly linked list, even if one pointer
>>> gets corrupt, there is other path to reach the destination.
>>>
>>>
>>> On Wed, Jun 1, 2011 at 1:24 PM, Ashish Goel  wrote:
>>>
 given a single linked list, there is a possibility of pointer
 corruption, modify the data structure to ensure that the data is not lost.

 in my view a skip list is a good option, any other solutions?

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

 --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>
>>>
>>> --
>>> Gaurav Aggarwal
>>> SCJP
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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] [brain teaser ] Trap Door puzzle 1 April

2011-06-01 Thread Logic King
nice one :)

On Wed, Jun 1, 2011 at 12:49 AM, Naveen Kumar wrote:

> Wait till night and walk through the first door.
>
>
> On Wed, Jun 1, 2011 at 12:44 PM, Lavesh Rawat wrote:
>
>> *Trap Door puzzle
>>  *
>> *
>> *
>> **
>> *A man is trapped in a room. The room has only two possible exits: two
>> doors. Through the first door there is a room constructed from magnifying
>> glass. The blazing hot sun instantly fries anything or anyone that enters.
>> Through the second door there is a fire-breathing dragon. How does the man
>> escape?
>> *
>>
>> *Update Your Answers at* : Click 
>> Here
>>
>>
>> Solution:
>> Will be updated after 1 day
>>
>>
>>
>>
>> --
>>
>> "Never explain yourself. Your friends don’t need it
>> and your enemies won’t believe it" .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Cheers
> Naveen 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Finding circle areas under dust bins

2011-05-31 Thread Logic King
If the number of people is large then putting the dustbin in hexagonal
fashion as we do in mobile networks should minimize the number of dustbin
...

On Tue, May 31, 2011 at 9:35 AM, ross  wrote:

> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] [brain teaser ] Trolls Riddle 31 may

2011-05-31 Thread Logic King
simple2 cakes !

On Tue, May 31, 2011 at 1:17 AM, Naveen Kumar wrote:

> 2 cakes.
>
>
> On Tue, May 31, 2011 at 12:48 PM, Lavesh Rawat wrote:
>
>> *Trolls Riddle
>>  *
>> *
>> *
>> **
>> *You are on your way to visit your Grandma, who lives at the end of the
>> valley. It's her birthday, and you want to give her the cakes you've made.
>>
>> Between your house and her house, you have to cross 7 bridges, and as it
>> goes in the land of make believe, there is a troll under every bridge! Each
>> troll, quite rightly, insists that you pay a troll toll. Before you can
>> cross their bridge, you have to give them half of the cakes you are
>> carrying, but as they are kind trolls, they each give you back a single
>> cake.
>>
>> How many cakes do you have to leave home with to make sure that you arrive
>> at Grandma's with exactly 2 cakes?
>> *
>> *
>> *
>>
>> *Update Your Answers at* : Click 
>> Here
>>
>>
>> Solution:
>> Will be updated after 1 day
>>
>>
>> --
>>
>> "Never explain yourself. Your friends don’t need it
>> and your enemies won’t believe it" .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Cheers
> Naveen 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] SPOJ Problem Help

2011-05-28 Thread Logic King
@sukhmeetyour code is having runtime error !!

On Sat, May 28, 2011 at 4:48 AM, sukhmeet singh wrote:

> follow what Akash said..!!
> in case you still need help just go through http://ideone.com/al0U0  in
> devcpp..!!
>
> On Sat, May 28, 2011 at 2:34 PM, Aakash Johari wrote:
>
>> Precompute the values. and then do queries.
>>
>>
>> On Sat, May 28, 2011 at 1:46 AM, Akshata Sharma <
>> akshatasharm...@gmail.com> wrote:
>>
>>> My code gives TLE. What further optimization is required in my code??
>>> https://www.spoj.pl/problems/FACVSPOW/
>>>
>>>
>>>
>>>
>>> /*FACVSPOW*/
>>> #include
>>>
>>>
>>>
>>> #include
>>>
>>>
>>>
>>>
>>> using namespace std;
>>>
>>>
>>>
>>>
>>> int calc(long n, long a)
>>>
>>>
>>>
>>> {
>>>  if(((n*log(n)-n)+0.5*log(2*M_PI*n)-n*log(a))>=0)
>>>
>>>
>>>
>>>
>>>  return 1;
>>>  else return -1;
>>>
>>>
>>>
>>> }
>>> int main()
>>>
>>>
>>>
>>> {
>>> long t;
>>> scanf("%ld",&t);
>>>
>>>
>>>
>>> long a;
>>> while(t--)
>>>
>>>
>>>
>>> {
>>>  scanf("%ld",&a);
>>>
>>>
>>>
>>>
>>>  long lo=2*a;
>>>
>>>
>>>
>>>
>>>  long hi=(long)(2.718281828*a) + 1;
>>>
>>>
>>>
>>>
>>>  long mid;
>>>  while(lo>>
>>>
>>>
>>>
>>>  {
>>>   mid=(lo+hi)/2;
>>>
>>>
>>>
>>>
>>>   if(calc(mid,a)<0)
>>>
>>>
>>>
>>>
>>>   lo=mid+1
>>>   else if(calc(mid,a)>0)
>>>
>>>
>>>
>>>
>>>   hi=mid;
>>>
>>>   if(calc(mid,a)>0 && calc(mid-1,a)<0)
>>>
>>>
>>>
>>>
>>>   break;
>>>  }
>>>   printf("%ld\n",mid);
>>>
>>>
>>>
>>> }
>>> 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.
>>>
>>
>>
>>
>> --
>> -Aakash Johari
>> (IIIT 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Odd Even Sort array

2011-05-27 Thread Logic King
@ross
i can do it in O(n) time using an extra array of the same size as the given
array

first sort both the even indexed terms and odd indexed terms by modifying
quick sort...it can be done in one traversal.

and then using extra array and then move the even indexed terms followed by
odd indexed terms
i think it should work..

if anyone have the idea that can reduce the space required then please share
!!

On Fri, May 27, 2011 at 1:29 PM, Piyush Sinha wrote:

> how large n will be...O(n) can't grow more than O(nlogn)so in any
> case the complexity is going to be O(nlogn)..so i dnt see any point of
> bringing our any modification of mergersort...even if u think so,
> provide a concrete algo
>
> On 5/28/11, LALIT SHARMA  wrote:
> > It will give correct answer ,
> > but instead of doing manipulation after taking input.
> > as it would take some O(n) time. if n would be large , we would incur
> > this extra cost .
> >
> > we should change the termination condition of merge-sort function and
> > modify the merge function of merge sort ..to reach our objective .
> >
> > correct me , if i am wrong ...
> >
> > On Sat, May 28, 2011 at 1:40 AM, Piyush Sinha 
> > wrote:
> >> main()
> >> {
> >>   int a[100];
> >>   int i,j,N;
> >>   printf("enter the number of elements: ");
> >>   scanf("%d",&N);
> >>   for(i=0;i >> scanf("%d",a[i]);
> >>   if(N%2) j = N/2+1;
> >>   else j = N/2;
> >>   i =1;
> >>   while(j >>   {
> >> swap(&a[i],&a[j]);
> >> i+=2;
> >> j+=2;
> >>   }
> >>   if(N%2){
> >>  inv_mergesort(a,0,N/2);//sort the array in descending order
> >>  mergesort(a,N/2+1,N-1);
> >>   }
> >>   else{
> >>inv_mergesort(a,0,N/2-1);//sort the array in descending order
> >> mergesort(a,N/2,N-1);
> >>   }
> >>
> >>   for(i=0;i >>  printf("%d",a[i]);
> >> }
> >>
> >> I hope the code doesn't contain any bugs...:P :P
> >>
> >> On 5/28/11, srajan dongre  wrote:
> >>> wat about insertion sort (with some limited conditions obviously )  ??
> >>>
> >>> On Sat, May 28, 2011 at 12:56 AM, Piyush Sinha
> >>> wrote:
> >>>
>  will it be given that the number of elements is always even??
> 
>  On 5/28/11, ross  wrote:
>  > Hi all,
>  >
>  > Sort all elements in odd indices of an array in ascending order and
>  > even indices in descending order.
>  > Finally, rearrange so that all even indexed elements come first.
>  >
>  > eg:
>  >
>  > input – 7 2 6 4 8 3 1
>  >
>  > even indexed : 7 6 8 1 => sort 8 7 6 1
>  > odd indexed: 2 4 3 => sort 2 3 4
>  >
>  > output – 8 7 6 1 2 3 4
>  >
>  > What could be the best algo to solve it?
>  > Is it possible to arrive at the output using only O(1) extra space?
>  >
>  > --
>  > You received this message because you are subscribed to the Google
>  > Groups
>  > "Algorithm Geeks" group.
>  > To post to this group, send email to algogeeks@googlegroups.com.
>  > To unsubscribe from this group, send email to
>  > algogeeks+unsubscr...@googlegroups.com.
>  > For more options, visit this group at
>  > http://groups.google.com/group/algogeeks?hl=en.
>  >
>  >
> 
> 
>  --
>  *Piyush Sinha*
>  *IIIT, Allahabad*
>  *+91-8792136657*
>  *+91-7483122727*
>  *https://www.facebook.com/profile.php?id=10655377926 *
> 
>  --
>  You received this message because you are subscribed to the Google
>  Groups
>  "Algorithm Geeks" group.
>  To post to this group, send email to algogeeks@googlegroups.com.
>  To unsubscribe from this group, send email to
>  algogeeks+unsubscr...@googlegroups.com.
>  For more options, visit this group at
>  http://groups.google.com/group/algogeeks?hl=en.
> 
> 
> >>>
> >>>
> >>> --
> >>> --
> >>>
> >>> Srajan Dongre
> >>> ||nd year  CSI (dual degree)
> >>> Indian Institute of Technology , Roorkee
> >>> Uttrakhand , India
> >>> pin code--247667
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Algorithm Geeks" group.
> >>> To post to this group, send email to algogeeks@googlegroups.com.
> >>> To unsubscribe from this group, send email to
> >>> algogeeks+unsubscr...@googlegroups.com.
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/algogeeks?hl=en.
> >>>
> >>>
> >>
> >>
> >> --
> >> *Piyush Sinha*
> >> *IIIT, Allahabad*
> >> *+91-8792136657*
> >> *+91-7483122727*
> >> *https://www.facebook.com/profile.php?id=10655377926 *
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to algogeeks@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> algogeeks+unsubscr...@googlegroups.com.
> >> For more options, vis

Re: [algogeeks] ms ques

2011-05-27 Thread Logic King
http://samples.msdn.microsoft.com/ietestcenter/


On Fri, May 27, 2011 at 9:40 AM, radha krishnan <
radhakrishnance...@gmail.com> wrote:

> Check whether this is storing  Google  Search Results ? ? ?? ? ? ? ? ??
> [HONEY POTTING]
>
>
> On Fri, May 27, 2011 at 10:07 PM, UTKARSH SRIVASTAV <
> usrivastav...@gmail.com> wrote:
>
>> test cases for internet explorer
>>
>> --
>> *UTKARSH SRIVASTAV
>> CSE-3
>> B-Tech 2nd Year
>> @MNNIT ALLAHABAD*
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: Google Interview Question

2011-05-27 Thread Logic King
@sunny it will work fine if you have 2 numbers only...but what about the
list...3..4 or 5..or morethen the possible number of combinations will
be  'N!'...where n is the number of digits...the code will work quite
slowly for larger 'n'.

On Fri, May 27, 2011 at 3:33 PM, Dave  wrote:

> @Shubham: Try 8, 89, 7. Your algorithm gives 8897, but the right
> answer is 8987.
>
> Dave
>
> On May 27, 1:11 pm, shubham  wrote:
> > check whether these steps work:
> >
> > step 1:
> > sort the given numbers in the decreasing order based on their
> first
> > digit.
> > step 2:
> > if two numbers come out to be equal in the above case & both of
> > their next digit exist then sort on the basis of their next digit,
> otherwise
> > the number
> > whose next digit doesnot exist should be placed before the other
> > number.
> > step 3:
> >concatenate these numbers.
> >
> > e.g.
> >
> > (0,1,10,100) sorting it gives: 1,10,100,0 => 1101000
> > (97,8,9) sorting gives: 9,97,8 => 9978
> >
> > correct me if i'm wrong.
> >
> > Shubham
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] one constructor problem

2011-05-27 Thread Logic King
@D.N. I Think if you removes default constructor and give only parametrized
constructor...then it i going to give any errorit should work fine..

On Fri, May 27, 2011 at 4:40 AM, Aakash Johari wrote:

> Provide some default value to the parameterized constructor.
> *
> A(int m = 0) {
> a = m;
> } *
>
> On Fri, May 27, 2011 at 4:36 AM, D.N.Vishwakarma@IITR 
> wrote:
>
>> without default constructor what will be solution
>>
>> On Wed, May 25, 2011 at 10:56 AM, Aakash Johari wrote:
>>
>>> This way you can do:
>>>
>>> #include 
>>>
>>> using namespace std;
>>>
>>> class A {
>>> public:
>>> int a;
>>>
>>> A(int m) {
>>> a = m;
>>> }
>>>
>>> A() {
>>> }
>>> };
>>>
>>> int main()
>>> {
>>> int i;
>>>
>>> A *obj[32];
>>>
>>> for ( i = 0; i <= 31; i++ ) {
>>> obj[i] = new A(i);
>>> }
>>>
>>> for ( i = 0; i <= 31; i++ ) {
>>> cout << obj[i]->a << endl;
>>> }
>>>
>>> return 0;
>>>
>>> }
>>>
>>> On Tue, May 24, 2011 at 9:38 PM, immanuel kingston <
>>> kingston.imman...@gmail.com> wrote:
>>>

 http://www.java2s.com/Tutorial/Cpp/0180__Class/Initializeanarrayofobjectsbyreferencingtheconstructordirectly.htm


 http://www.java2s.com/Tutorial/Cpp/0180__Class/Initializeanarrayofobjectswithoutreferencingtheconstructordirectly.htm

 Thanks,
 Immanuel



 On Wed, May 25, 2011 at 7:34 AM, D.N.Vishwakarma@IITR <
 deok...@gmail.com> wrote:

> There is a class A which contains just one parameterized constructor
> A(int a). How would you initialize an array of objects of this class.
>
> --
> **With Regards
> Deoki Nandan Vishwakarma
> IITR MCA
> Mathematics Department*
> *
>
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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.

>>>
>>>
>>>
>>> --
>>> -Aakash Johari
>>> (IIIT 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.
>>>
>>
>>
>>
>> --
>> **With Regards
>> Deoki Nandan Vishwakarma
>> IITR MCA
>> Mathematics Department*
>> *
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> -Aakash Johari
> (IIIT 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] Google Interview Question

2011-05-27 Thread Logic King
i agree with piyush...can't find the countercase...satisfied with the algo.

On Fri, May 27, 2011 at 6:58 AM, Piyush Sinha wrote:

> how about adding zeroes at the end of integers to make to equal to the
> integer with maximum number of digits and sort them...
>
> ex-
> 101 10
>
> adding zeroes..
> 101 100
>
> sort 100 101
>
> therefore make number as 10110
>
> 100 1
>
> adding zeroes
> 100 100
>
> therefore number is 1100
>
> I am not sure of the method.if there is any counter case please do
> suggest...
>
> On 5/27/11, wujin chen  wrote:
> > @radha,  i think your solution is wrong.
> > for this case: 101,10
> > in your solution , the ans is 10101,but the max ans is 10110.
> >
> > 2011/5/27 radha krishnan 
> >
> >> 10100 is max ans
> >> okay
> >> convert the numbers to strings and sort based on the first character
> >> !!!
> >> if equal do that recursively  and then if length is less give that
> >> preference !!
> >> i think this solution ..
> >> may be this is wrong !!
> >>
> >> On Fri, May 27, 2011 at 7:07 PM, wujin chen  >wrote:
> >>
> >>> @Piyush, how to deal with this case :100 , 10
> >>>
> >>>
> >>> 2011/5/27 Piyush Sinha 
> >>>
>  we can work out if we sort according to the leftmost integer
> 
>  On 5/27/11, adityasir...@gmail.com  wrote:
>  > are you kidding me. Just simple sort wont work.
>  >
>  > On Fri, May 27, 2011 at 9:31 AM, radha krishnan <
>  > radhakrishnance...@gmail.com> wrote:
>  >
>  >> sort :)
>  >>
>  >>
>  >> On Fri, May 27, 2011 at 6:57 PM, ross 
> wrote:
>  >>
>  >>> Hi all,
>  >>>
>  >>> Given an array of elements find the largest possible number that
> can
>  >>> be formed by using the elements of the array.
>  >>>
>  >>> eg: 10 9
>  >>> ans: 910
>  >>>
>  >>> 2 3 5 78
>  >>>
>  >>> ans: 78532
>  >>>
>  >>> 100 9
>  >>>
>  >>> ans: 9100
>  >>>
>  >>> --
>  >>> You received this message because you are subscribed to the Google
>  Groups
>  >>> "Algorithm Geeks" group.
>  >>> To post to this group, send email to algogeeks@googlegroups.com.
>  >>> To unsubscribe from 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.
>  >
>  >
> 
> 
>  --
>  *Piyush Sinha*
>  *IIIT, Allahabad*
>  *+91-8792136657*
>  *+91-7483122727*
>  *https://www.facebook.com/profile.php?id=10655377926 *
> 
>  --
>  You received this message because you are subscribed to the Google
>  Groups
>  "Algorithm Geeks" group.
>  To post to this group, send email to algogeeks@googlegroups.com.
>  To unsubscribe from 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://gro

Re: [algogeeks] Re: Spoj Problem Help

2011-05-24 Thread Logic King
@aakash
the cases are clear but can you explain how you did the matrix
exponentiation part ??..explain plz...i'm not getting it...

On Tue, May 24, 2011 at 1:25 AM, Aakash Johari wrote:

> It's done. Today I tried it.
>
> Simply for N=0 and N=1 answer is (0,0) = 0 and (1,1)=2 respectively.
>
> For other cases, you can get the solution with fib(N+3). Starting fib(1) =
> 1, fib(2) = 1...
>
> Matrix Exponentiation, and Modulus for given constraints are necessary to
> pass the solution.
>
>
>
> On Mon, May 23, 2011 at 11:58 PM, sravanreddy001  > wrote:
>
>> @Dave,Balaji,Samby.. Without the matrix exponentiation, the time is not
>> possible, and without using the intermediate modulo operater as suggested by
>> Dave, the value cannot be accommodated, as the 300th fibinocci number alone
>> comes to
>> --> 3224462942044552973989346190996720939096499764990979600
>> So, a mix of both are needed.. I'll try to look into this.
>>
>> any alternate solution you can think of?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> -Aakash Johari
> (IIIT 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] A SIMPLE C++ PROGRAM.

2011-05-03 Thread Logic King
What about the people explaining the answer above as '12'saying
processing will start from left in cout and write in printf ??

On Sun, May 1, 2011 at 1:33 AM, Amit Jaspal  wrote:

> This is compiler dependent..and not a portable way of writing code
>
>
> On Sat, Apr 30, 2011 at 12:11 PM, Ashish Modi wrote:
>
>>  For such type of questions, the best method is to draw a parse
>> tree according to precedence  and evaluate the tree. This is how it is
>> evaluated at compiler level. Many times parsing tree creation is
>> implementation dependent.
>>
>>
>>
>>
>>
>>
>> On Fri, Apr 29, 2011 at 6:43 PM, Varun Nagpal wrote:
>>
>>> I think these questions are stupid in the sense that no one would ever
>>> use these constructs in their production code unless someone wants to write
>>> an obscure obfuscated code in some competition. Many times similar
>>> expressions are non-portable.
>>>
>>> Anyways, to understand this and related concepts, please see iso c or c++
>>> standard and try to understand operator precedence, operator associativity
>>> and sequence points.
>>>
>>> On Fri, Apr 29, 2011 at 3:06 PM, Nikhil Gupta >> > wrote:
>>>
 12
 5

 because y=4+4+3+1
 and x is incremented to 5


 On Fri, Apr 29, 2011 at 2:01 PM, MANNU  wrote:

> *Can anyone please explain me the output of this program:*
>
> int x=1;
> int y=x++ + ++x + ++x + x++;
> cout< cout<
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India

  --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.
>>>
>>
>>
>>
>> --
>> With Regards
>> Ashish Modi
>> 9423721478
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Amit Jaspal.
>
> Men do less than they ought,
> unless they do all they can
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: imporatnt(need help)

2011-04-28 Thread Logic King
@utkarsh that's very rude...you can't say about anyone like this.who
knows you may be writing the man pages in the future :P

On Thu, Apr 28, 2011 at 10:21 AM, UTKARSH SRIVASTAV  wrote:

>
>
> i think mca students need to first study and then try to answer people like
> saurabh(.bashrc) and kaml is really not innocent but a cheater and this is
> really a disgrace to anyone remotely related with coding .All the MCA guys
> supporting them you should leave coding and should write man pages to b-tech
> students and documentations for notepad..
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] spoj problem

2011-03-15 Thread Logic King
i Agree.the test cases for which problem is being jugdged might not have
those larger values.


On Tue, Mar 15, 2011 at 12:20 PM, UTKARSH SRIVASTAV  wrote:

> well i have a doubt the test case says number could be as large as
> 10 and you have taken int but int does not have such range then how
> it is accepted
>
>
> On Sat, Mar 12, 2011 at 7:57 PM, Logic King wrote:
>
>> Here is my solution.i got it AC
>>
>> #include
>> int gcd(int a, int b)
>> {   int temp;
>>while(b)
>>{
>>temp = a % b;
>>a = b;
>>b = temp;
>>}
>> return(a);
>> }
>>
>> int main()
>> {
>>int n,i,min,ans=0;
>>scanf("%d",&n);
>>int arr[n],ard[n];
>>ard[0]=1;
>>if(n>0)
>>scanf("%d",&arr[0]);
>>for(i=1;i>{
>>scanf("%d",&arr[i]);
>>ard[i]=arr[i]-arr[i-1];
>>if(i==1)
>>min=ard[i];
>>else
>>min=gcd(min,ard[i]);
>>
>>}
>>for(i=1;i>{
>>ans+=((ard[i]/min)-1);
>>}
>>printf("%d",ans);
>> return 0;
>>
>> }
>>
>>
>>
>> On Sat, Mar 12, 2011 at 7:37 PM, Balaji Ramani > > wrote:
>>
>>> Yeah, I too am wondering how to implement more efficiently.
>>>
>>>
>>> On Sat, Mar 12, 2011 at 7:36 PM, Satyam Kapoor >> > wrote:
>>>
>>>>
>>>>
>>>> @balaji:i hve got ac with gcd method but the time is 0.32 sec
>>>>  best soln is 0.03
>>>> how is that achievable?
>>>> --
>>>> Satyam Kapoor
>>>> B.Tech 2nd year
>>>> Computer Science And Engineering
>>>> M.N.N.I.T 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.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> *UTKARSH SRIVATAV*
> *CSE-3
> B-Tech 2nd Year
> @MNNIT ALLAHABAD*
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Spoj Problem : String based

2011-03-14 Thread Logic King
I don't Know what's KMP algorithm..i am just trying to solve this
problem on my own

On Tue, Mar 15, 2011 at 1:55 AM, ritu  wrote:

> Could you please explain ..whts the difference b/w KMP Algorithm and
> This problem.
> KMP also finds all  occurrences of a string in text
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Spoj Problem : String based

2011-03-13 Thread Logic King
U didn't understand my problem.i have the problem with this line --

"The length of the needle is only limited by the memory available to your
program, so do not make any assumptions - instead, read the length and
allocate memory as needed."

On Sun, Mar 13, 2011 at 4:00 PM, sukhmeet singh wrote:

> in order to deal with such situations u have to read the input till the end
> of file
> if your algo is correct then using EOF something like
> while(scanf("%d",&n)!=EOF) will give u AC..!!
>
> On Sun, Mar 13, 2011 at 2:01 PM, Logic King wrote:
>
>>  I tried the problem https://www.spoj.pl/problems/NHAY/
>>
>> I didn't Understand the Input of the problem --
>> The length of the needle is only limited by the memory available to your
>> program, so do not make any assumptions - instead, read the length and
>> allocate memory as needed. The haystack is *not* limited in size, which
>> implies that your program should not read the whole haystack at once. The
>> KMP algorithm is stream-based, i.e. it processes the haystack character by
>> character, so this is not a problem.
>>
>> my code works fine i the size of both the strings are limited
>>
>> i created my own algo...didn't did it by KMP.plz help me how to
>> control the large input !!
>>
>>
>> my code is--
>>
>> #include
>> #include
>>
>> int main()
>> {
>> int t,i,j,n,l1,l2;
>> char p[1000],str[1000];
>> scanf("%d",&t);
>> while(t--)
>> {
>> scanf("%d",&n);
>> i=0;
>> scanf("%s",p);
>> scanf("%s",str);
>> l1=strlen(str);l2=strlen(p);
>> for(j=0;j> {
>>
>> if(i> {
>> if(str[i]==p[j])
>> {
>> if(j==l2-1)
>> {
>> printf("%d\n",i-l2+1);
>> j=0;
>> i=i-l2+2;
>> }
>> else
>> {
>> i++;
>> j++;
>> }
>> }
>> else
>> {
>> if(j==0)
>> i++;
>> else
>> j=0;
>> }
>> }
>> else
>> break;
>> }
>> printf("\n");
>> }
>> 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Spoj Problem : String based

2011-03-13 Thread Logic King
I tried the problem https://www.spoj.pl/problems/NHAY/

I didn't Understand the Input of the problem --
The length of the needle is only limited by the memory available to your
program, so do not make any assumptions - instead, read the length and
allocate memory as needed. The haystack is *not* limited in size, which
implies that your program should not read the whole haystack at once. The
KMP algorithm is stream-based, i.e. it processes the haystack character by
character, so this is not a problem.

my code works fine i the size of both the strings are limited

i created my own algo...didn't did it by KMP.plz help me how to control
the large input !!


my code is--

#include
#include

int main()
{
int t,i,j,n,l1,l2;
char p[1000],str[1000];
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
i=0;
scanf("%s",p);
scanf("%s",str);
l1=strlen(str);l2=strlen(p);
for(j=0;jhttp://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] spoj problem

2011-03-12 Thread Logic King
Here is my solution.i got it AC

#include
int gcd(int a, int b)
{   int temp;
   while(b)
   {
   temp = a % b;
   a = b;
   b = temp;
   }
return(a);
}

int main()
{
   int n,i,min,ans=0;
   scanf("%d",&n);
   int arr[n],ard[n];
   ard[0]=1;
   if(n>0)
   scanf("%d",&arr[0]);
   for(i=1;iwrote:

> Yeah, I too am wondering how to implement more efficiently.
>
>
> On Sat, Mar 12, 2011 at 7:36 PM, Satyam Kapoor 
> wrote:
>
>>
>>
>> @balaji:i hve got ac with gcd method but the time is 0.32 sec
>>  best soln is 0.03
>> how is that achievable?
>> --
>> Satyam Kapoor
>> B.Tech 2nd year
>> Computer Science And Engineering
>> M.N.N.I.T 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] SPOJ DP : SUMITR

2011-03-08 Thread Logic King
I submitted it in g++4.3.2 it was AC...but acc. to you it should
have been error...i think you are wrong somewhere !!

On Tue, Mar 8, 2011 at 10:46 PM, abhijith reddy wrote:

>  isn't required for C++ 4.0.*. The same code will give Compile
> Error in C++ 4.3 and above
>
>
>
> On Tue, Mar 8, 2011 at 10:42 PM, Logic King wrote:
>
>> Well tried,
>>i have got the correct answer after working on it for almost 2 hours
>> here is my code
>>
>> #include
>> using namespace std;int a[100][100];main(){int
>> t,n,i,j;cin>>t;while(t--){cin>>n;for(i=0;i>a[i][j];}for(i=n-2;i>=0;i--){for(j=0;j<=i;j++){a[i][j]+=max(a[i+1][j],a[i+1][j+1]);}}cout<>
>>
>> 246 bytes in c++.i got it AC :)
>> one amazing thing i found in my code, while reducing number of bytes,
>> i.e.in my code max function is working even without using Algorithm
>> header filei dont know why it is working but it is workingif
>> anyone know the reason for this then please share it
>>
>> Thank you,
>> Logic King
>>
>> On Mon, Mar 7, 2011 at 8:25 PM, Wladimir Tavares 
>> wrote:
>>
>>> This my code:
>>> #include 
>>> #define R(i,b) for(i=0;i>> #define D(i,a) for(i=a;i>=0;i--)
>>>
>>> #define I(d) scanf("%d",&d);
>>>
>>> main(){int t,n,i,j,m[100][100];I(t)
>>> while(t--){I(n)R(i,n)R(j,i+1)I(m[i][j]) D(i,n-2)R(j,i+1)m[i][j] += m[i+1][j]
>>> > m[i+1][j+1]?m[i+1][j]:m[i+1][j+1];printf("%d\n",m[0][0]);}}
>>>
>>>
>>> 297 bytes!
>>>
>>>
>>>
>>>
>>> On Mon, Mar 7, 2011 at 11:45 AM, Wladimir Tavares >> > wrote:
>>>
>>>> I create some macros like this:
>>>>
>>>> #define R(i,a,b) for(i=a;i>>> #define D(i,a,b) for(i=a;i>=b;i--)
>>>> #define I(d) scanf("%d",&d);
>>>>
>>>>
>>>>
>>>> But i don't get the accepted in this problem!
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Sun, Mar 6, 2011 at 1:55 PM, Logic King 
>>>> wrote:
>>>>
>>>>> i solved the problem on spoj based on DP i am getting the solution
>>>>> right but i am exceeding the following restriction
>>>>> "Take care about your fingers, do not use more than *256* bytes of
>>>>> code."
>>>>>
>>>>> http://www.spoj.pl/problems/SUMITR/
>>>>>
>>>>>
>>>>> My code is--
>>>>>
>>>>> #include
>>>>> int arr[100][100];
>>>>> int main()
>>>>> {
>>>>> int tc,n,max,i,j;
>>>>> scanf("%d",&tc);
>>>>> while(tc--)
>>>>> {
>>>>> scanf("%d",&n);
>>>>> for(i=0;i>>>> {
>>>>> for(j=0;j<=i;j++)
>>>>> scanf("%d",&arr[i][j]);
>>>>> }
>>>>> for(i=n-2;i>=0;i--)
>>>>> {
>>>>> for(j=0;j<=i;j++)
>>>>> {
>>>>>
>>>>> max=(arr[i+1][j]>arr[i+1][j+1])?arr[i+1][j]:arr[i+1][j+1];
>>>>> arr[i][j]=arr[i][j]+max;
>>>>> }
>>>>> }
>>>>> printf("%d\n",arr[0][0]);
>>>>> }
>>>>> return 0;
>>>>> }
>>>>>
>>>>>
>>>>> how can i reduce my my code length so that it doesn't exceed 256
>>>>> bytespl 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.
>>>>>
>>>>
>>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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] SPOJ DP : SUMITR

2011-03-08 Thread Logic King
Well tried,
   i have got the correct answer after working on it for almost 2 hours
here is my code

#include
using namespace std;int a[100][100];main(){int
t,n,i,j;cin>>t;while(t--){cin>>n;for(i=0;i>a[i][j];}for(i=n-2;i>=0;i--){for(j=0;j<=i;j++){a[i][j]+=max(a[i+1][j],a[i+1][j+1]);}}cout<wrote:

> This my code:
> #include 
> #define R(i,b) for(i=0;i #define D(i,a) for(i=a;i>=0;i--)
>
> #define I(d) scanf("%d",&d);
>
> main(){int t,n,i,j,m[100][100];I(t) while(t--){I(n)R(i,n)R(j,i+1)I(m[i][j])
> D(i,n-2)R(j,i+1)m[i][j] += m[i+1][j] >
> m[i+1][j+1]?m[i+1][j]:m[i+1][j+1];printf("%d\n",m[0][0]);}}
>
>
> 297 bytes!
>
>
>
>
> On Mon, Mar 7, 2011 at 11:45 AM, Wladimir Tavares 
> wrote:
>
>> I create some macros like this:
>>
>> #define R(i,a,b) for(i=a;i> #define D(i,a,b) for(i=a;i>=b;i--)
>> #define I(d) scanf("%d",&d);
>>
>>
>>
>> But i don't get the accepted in this problem!
>>
>>
>>
>>
>>
>>
>> On Sun, Mar 6, 2011 at 1:55 PM, Logic King wrote:
>>
>>> i solved the problem on spoj based on DP i am getting the solution right
>>> but i am exceeding the following restriction
>>> "Take care about your fingers, do not use more than *256* bytes of
>>> code."
>>>
>>> http://www.spoj.pl/problems/SUMITR/
>>>
>>>
>>> My code is--
>>>
>>> #include
>>> int arr[100][100];
>>> int main()
>>> {
>>> int tc,n,max,i,j;
>>> scanf("%d",&tc);
>>> while(tc--)
>>> {
>>> scanf("%d",&n);
>>> for(i=0;i>> {
>>> for(j=0;j<=i;j++)
>>> scanf("%d",&arr[i][j]);
>>> }
>>> for(i=n-2;i>=0;i--)
>>> {
>>> for(j=0;j<=i;j++)
>>> {
>>>
>>> max=(arr[i+1][j]>arr[i+1][j+1])?arr[i+1][j]:arr[i+1][j+1];
>>> arr[i][j]=arr[i][j]+max;
>>> }
>>> }
>>> printf("%d\n",arr[0][0]);
>>> }
>>> return 0;
>>> }
>>>
>>>
>>> how can i reduce my my code length so that it doesn't exceed 256
>>> bytespl 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.
>>>
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: SPOJ Problem

2011-03-06 Thread Logic King
Has anyone solve this problem ??

On Fri, Mar 4, 2011 at 11:18 PM, Logic King wrote:

> I am trying to solve the problem https://www.spoj.pl/problems/PHRASES/
>
> but i am not getting how to approach the problem
>
> plz help 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.



Re: [algogeeks] SPOJ PROBLEM

2011-03-06 Thread Logic King
U didn't read my post completely.i know the test cases where my
code..Actually i want the correct logic/solution for the
solutioni know my code is wrongi failed to apply DP in my
code.plz help !!

On Sun, Mar 6, 2011 at 1:32 AM, Arpit Sood  wrote:

> where is dp in your code ? btw, there is a spoj forum, you should search
> over there and you will get the required test cases where your code fails.
>
> Cheers!
>
> On Sat, Mar 5, 2011 at 11:45 PM, Logic King wrote:
>
>> i tried to solve the problem on spoj https://www.spoj.pl/problems/TRT/
>> the problem is based on DP
>>
>> i coded the problem as  
>>
>> #include
>> #include
>> #include
>> int arr[2000];
>> int main()
>> {
>> int i,l,r,age=1,n,sum=0;
>> scanf("%d",&n);
>> l=0,r=n-1;
>> for(i=0;i> scanf("%d",&arr[i]);
>> for(i=0;i> {
>> if(arr[l]<=arr[r])
>> {
>> sum+=arr[l]*age;
>> l++;
>> age++;
>> }
>> else
>> {
>> sum+=arr[r]*age;
>> r--;
>> age++;
>> }
>> }
>> printf("%d\n",sum);
>> return 0;
>> }
>>
>>
>> but i am getting WA on submission
>> Actually my code fails on some of the test cases like
>> INPUT-
>> 6
>> 21
>> 31
>> 12
>> 3
>> 4
>> 33
>>
>>
>>
>> The algorithm i use would give 349 (21*1 + 31*2 + 12*3 + 3*4 + 4*5 + 33*6)
>> as the answer.
>>
>> But the correct answer is 389 with sequence of picking as(33, 4, 3, 12,
>> 21, 31).
>>
>> plz help me improve my algorithm !!
>>
>> thanking in advance
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] SPOJ DP : SUMITR

2011-03-06 Thread Logic King
i solved the problem on spoj based on DP i am getting the solution right but
i am exceeding the following restriction
"Take care about your fingers, do not use more than *256* bytes of code."

http://www.spoj.pl/problems/SUMITR/


My code is--

#include
int arr[100][100];
int main()
{
int tc,n,max,i,j;
scanf("%d",&tc);
while(tc--)
{
scanf("%d",&n);
for(i=0;i=0;i--)
{
for(j=0;j<=i;j++)
{

max=(arr[i+1][j]>arr[i+1][j+1])?arr[i+1][j]:arr[i+1][j+1];
arr[i][j]=arr[i][j]+max;
}
}
printf("%d\n",arr[0][0]);
}
return 0;
}


how can i reduce my my code length so that it doesn't exceed 256 bytespl
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.



[algogeeks] SPOJ PROBLEM

2011-03-05 Thread Logic King
i tried to solve the problem on spoj https://www.spoj.pl/problems/TRT/
the problem is based on DP

i coded the problem as  

#include
#include
#include
int arr[2000];
int main()
{
int i,l,r,age=1,n,sum=0;
scanf("%d",&n);
l=0,r=n-1;
for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: A simple Mathematical spoj Problem

2011-03-04 Thread Logic King
Thanks dave !! ..i got the point :)

On Sat, Mar 5, 2011 at 2:36 AM, Dave  wrote:

> @LK: It looks like you are assuming that the maximum range will occur
> if he throws the arrows upwards at a 45 degree angle. While this
> provides the maximum range if H = 0, it does not do so for other
> values of H. See http://en.wikipedia.org/wiki/Range_of_a_projectile
> for a derivation of the optimal angle for what they call "uneven
> ground."
>
> Dave
>
> On Mar 4, 2:43 pm, Logic King  wrote:
> > I solved the problem  https://www.spoj.pl/problems/FTHEELF/
> >
> > i dont know why i am WA..plz tell why it getting WA...if
> there
> > are cases where my code fails please specify !!
> >
> > #include
> > #include
> > int main()
> > {
> > int v,h;
> > long double t,d,g=9.8L;
> > while(1)
> > {
> > scanf("%d%d",&v,&h);
> > if(v==-1&&h==-1)
> > return 0;
> > else
> > {
> >
> >
> t=(2*v*(1/sqrtl(2))+sqrtl((4*v*v*(1/sqrtl(2))*(1/sqrtl(2)))+8*h*g))/(2*g);
> > d=v*(1/sqrtl(2))*t;
> > printf("%.6Lf\n",d);
> > }
> > }
> > return 0;
> >
> >
> >
> > }- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] A simple Mathematical spoj Problem

2011-03-04 Thread Logic King
I solved the problem   https://www.spoj.pl/problems/FTHEELF/

i dont know why i am WA..plz tell why it getting WA...if there
are cases where my code fails please specify !!


#include
#include
int main()
{
int v,h;
long double t,d,g=9.8L;
while(1)
{
scanf("%d%d",&v,&h);
if(v==-1&&h==-1)
return 0;
else
{

t=(2*v*(1/sqrtl(2))+sqrtl((4*v*v*(1/sqrtl(2))*(1/sqrtl(2)))+8*h*g))/(2*g);
d=v*(1/sqrtl(2))*t;
printf("%.6Lf\n",d);
}
}
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.



[algogeeks] SPOJ Problem

2011-03-04 Thread Logic King
I am trying to solve the problem https://www.spoj.pl/problems/PHRASES/

but i am not getting how to approach the problem

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



Re: [algogeeks] printing without loop

2011-03-01 Thread Logic King
yes..the solution given by sunny is awesome...well done !!

On Tue, Mar 1, 2011 at 6:25 PM, priya mehta wrote:

> @sunny This is awesome
>
>
> On Tue, Mar 1, 2011 at 6:25 PM, priya mehta wrote:
>
>> This is awesome 
>>
>> On Tue, Mar 1, 2011 at 1:27 PM, sunny agrawal wrote:
>>
>>> int i=1;
>>> #define PRINT1 cout<>> #define PRINT2 PRINT1 PRINT1
>>> #define PRINT4 PRINT2 PRINT2
>>> #define PRINT8 PRINT4 PRINT4
>>> #define PRINT16 PRINT8 PRINT8
>>> #define PRINT32 PRINT16 PRINT16
>>> #define PRINT64 PRINT32 PRINT32
>>>
>>> int main()
>>> {
>>>  //as 100 = (1100100); we need to use PRINT64, PRINT32, and PRINT4
>>>  PRINT64;
>>>  PRINT32;
>>>  PRINT4;
>>> }
>>>
>>>
>>> This will print 1 to 100. You can use this code to print from 1 to x
>>> (x<=128). You can extend it to larger numbers, by adding PRINT128,
>>> PRINT256...etc.
>>>
>>> On 3/1/11, preetika tyagi  wrote:
>>> > May be we can use *goto *statement?
>>> >
>>> > On Mon, Feb 28, 2011 at 10:36 PM, gaurav gupta
>>> > <1989.gau...@googlemail.com>wrote:
>>> >
>>> >> Questions is : You have to print 1 to n without using any loop( for,
>>> >> while,
>>> >> do-while, goto ) and recursion.
>>> >>
>>> >> Any suggestion?
>>> >>
>>> >>
>>> >> On Tue, Mar 1, 2011 at 10:52 AM, preetika tyagi
>>> >> wrote:
>>> >>
>>> >>> Can you elaborate on it and provide more details?
>>> >>>
>>> >>>
>>> >>> On Mon, Feb 28, 2011 at 10:14 PM, Subhransupanigrahi <
>>> >>> subhransu.panigr...@gmail.com> wrote:
>>> >>>
>>>  Is there any way to print 1 to 10 (taking an example, it can also
>>> extend
>>>  to 100) without using loop, recursion.
>>> 
>>> 
>>>  Sent from my iPhone
>>> 
>>>  --
>>>  You received this message because you are subscribed to the Google
>>>  Groups
>>>  "Algorithm Geeks" group.
>>>  To post to this group, send email to algogeeks@googlegroups.com.
>>>  To unsubscribe from this group, send email to
>>>  algogeeks+unsubscr...@googlegroups.com.
>>>  For more options, visit this group at
>>>  http://groups.google.com/group/algogeeks?hl=en.
>>> 
>>> 
>>> >>>  --
>>> >>> You received this message because you are subscribed to the Google
>>> Groups
>>> >>> "Algorithm Geeks" group.
>>> >>> To post to this group, send email to algogeeks@googlegroups.com.
>>> >>> To unsubscribe from this group, send email to
>>> >>> algogeeks+unsubscr...@googlegroups.com.
>>> >>> For more options, visit this group at
>>> >>> http://groups.google.com/group/algogeeks?hl=en.
>>> >>>
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Thanks & Regards,
>>> >> Gaurav Gupta
>>> >> 7676-999-350
>>> >>
>>> >> "Quality is never an accident. It is always result of intelligent
>>> effort"
>>> >> -
>>> >> John Ruskin
>>> >>
>>> >>
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "Algorithm Geeks" group.
>>> > To post to this group, send email to algogeeks@googlegroups.com.
>>> > To unsubscribe from 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] making a graphical c++ programme

2011-02-25 Thread Logic King
I also want to know how to start making graphical program in c++..also
can we integrate database with a c++ application.

actually i want to make a c++ application using both c++ and
databasehow should i start please guide me !!!

On Sat, Feb 26, 2011 at 1:20 AM, UTKARSH SRIVASTAV
wrote:

> can anybody give me code of making a simple c++ graphical program.
> please also write statement of compiling and running the program in
> linux.
> and if you wish please explain the statements of program with
> comments...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Easy problem but unable to handle large input

2011-02-04 Thread Logic King
Now,this is a very basic and very easy problem on SPOJ

but again i failed to handle large inputs..someone please help me to
get this AC

https://www.spoj.pl/problems/JULKA/

My code which gave wrong answer is---

#include
int main()
{
long long int k,n,i,x1,x2;
for(i=0;i<10;i++)
{
scanf("%lld",&x1);
scanf("%lld",&x2);
k=(x1+x2)/2;
n=(x1-x2)/2;
printf("%lld\n%lld\n",k,n);
}
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.



[algogeeks] BISHOPS

2011-02-04 Thread Logic King
please help me solve the problem on SPOJ

https://www.spoj.pl/problems/BISHOPS/


The logic of the problem is very easy i.e. 2*n-2
but i am getting WA bcoz i am not able to deal with the large inputs.[?]
plz help me how to get this AC.


#include
int main()
{
long long int n,bmax;
while(scanf("%lld",&n)!=EOF)
{
if(n==1)
printf("%d\n",1);
else
{
bmax=(2*n)-2;
printf("%lld\n",bmax);

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

<<325.png>>

Re: [algogeeks] Re: SPOJ PROBLEM

2011-02-04 Thread Logic King
@juver++
thanks, learned about Unicode today !!

On Fri, Feb 4, 2011 at 12:48 PM, juver++  wrote:

> It is unicode I think.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: SPOJ PROBLEM

2011-02-03 Thread Logic King
@juver++

Is the sign you printed anywhere on keyboard ?
how can u use it ??
i got AC althoughis there any *ALTERNATIVE SOLUTION *




On Thu, Feb 3, 2011 at 8:26 PM, rahul rai  wrote:

>
> does this has to do with floating point representation of numbers {IEE 754}
> {single precision  }
> then the number would be
> like
> like for 32 bit field
>
> put 0 in the sign field
> all 1 in biased exponent field{8}
> and all zeros in the mantissa field{23}
>
> http://en.wikipedia.org/wiki/Single_precision_floating-point_format
>
> also infinity is not equal to {1/machine tolerance=(2^-23)} for some
> machines
>
> one thing for sure is that
> you can never come up with something bigger by adding one to {infinity}
> and never subtract 1 from machine tolerance
>
>
> correct me if i am wrong please
>
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: SPOJ PROBLEM

2011-02-03 Thread Logic King
How to get this AC..
what is the symbol of infinity ?
i wouls like to hear solutions in C

On Thu, Feb 3, 2011 at 9:46 AM, Sreeprasad Govindankutty <
sreeprasad...@gmail.com> wrote:

>  in java :  BigDecimal_MAX  ?
>
>
> On Wed, Feb 2, 2011 at 10:58 PM, Bhavesh agrawal wrote:
>
>> sry i does not help me
>>
>>
>> On Wed, Feb 2, 2011 at 10:59 PM, nishaanth  wrote:
>>
>>> how about put INT_MAX ..if we add 1 there will be a overflow right ?
>>>
>>>
>>> On Wed, Feb 2, 2011 at 10:50 PM, Logic King 
>>> wrote:
>>>
>>>> I have submitted the code of the same problem on spoj in C
>>>>  as
>>>>
>>>> #include
>>>> int main()
>>>> {
>>>> printf("&infin\n");
>>>> return 0;
>>>> }
>>>>
>>>>
>>>> this code represents the infinity i suppose then why i am getting WA !!
>>>>
>>>> On Wed, Feb 2, 2011 at 10:30 PM, juver++  wrote:
>>>>
>>>>> Output infinity sign :)
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from 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.
>>>>
>>>
>>>
>>>
>>> --
>>> S.Nishaanth,
>>> Computer Science and engineering,
>>> IIT Madras.
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Thanks and many regards,
> Sreeprasad Govindankutty
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: SPOJ PROBLEM

2011-02-02 Thread Logic King
I have submitted the code of the same problem on spoj in C
 as

#include
int main()
{
printf("&infin\n");
return 0;
}


this code represents the infinity i suppose then why i am getting WA !!

On Wed, Feb 2, 2011 at 10:30 PM, juver++  wrote:

> Output infinity sign :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] MBINGO

2011-01-24 Thread Logic King
help me solve the problem...how to approach the problem ??

https://www.spoj.pl/problems/MBINGO/

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Good Maths Question

2011-01-24 Thread Logic King
hey, but what's the solution to the problem...how to calculate the
ratio ??

On Mon, Jan 24, 2011 at 11:19 PM, juver++  wrote:

> @fight :) it's only for my pleasure :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Recursive Function For insertion in BST

2011-01-16 Thread Logic King
i agree with you.the head in the function is different from what it
is in the main() as it is not global..so it doesnt get modified
thnx :)

On Sun, Jan 16, 2011 at 11:21 AM, pacific pacific wrote:

> #include 
> #include 
> struct node {
>   int a ;
> };
>
> int insert(struct node * head  )
> {
>   struct node * temp;
>   temp= (struct node *) malloc(sizeof(struct node ));
>   printf("temp in function  %d \n",temp);
>   head = temp;
> }
>
> int main()
> {
>   struct node * temp;
>   temp= (struct node *) malloc(sizeof(struct node ));
>   printf(" temp before function  %d\n ",temp);
>   insert(temp);
>   printf(" temp after function %d\n ",temp);
> }
>
> Output :
> temp before function  167862280
>  temp in function  167862296
>  temp after function 167862280
>
> The assignment in the function insert to the head doesn't affect in the
> caller.I hope this example clears the doubt.
>
> I suggest an implementation like this ,
> struct node * insert(struct node * head , int data )  which returns the
> head of the tree to the caller.
>
> Let me know if i'm wrong anywhere.
>
> On Sun, Jan 16, 2011 at 12:34 AM, juver++  wrote:
>
>> @above
>> Of course, NO.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> regards,
> chinna.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Recursive Function For insertion in BST

2011-01-15 Thread Logic King
is there any difference between

struct node *lchild;

and

struct node* lchild;   ??

On Sat, Jan 15, 2011 at 6:42 PM, manoj lalavat wrote:

> http://cslibrary.stanford.edu/110/
>
>
>
> On Sat, Jan 15, 2011 at 6:36 PM, Logic King wrote:
>
>> hello all,
>> i am a beginner to data structures.I have created a recursive function
>> for insertion of a node in BST,but the function is not working
>> properly.plz correct me,probably i am doing something wrong with
>> the pointers
>> help required :( .urgent !!
>> the function is here---
>>
>>void insert(struct node *head,int info)
>>{
>>struct node *temp=malloc(sizeof(struct node));
>>temp->data=info;
>>temp->rchild=NULL;
>>temp->lchild=NULL;
>>if(head==NULL)
>>head=temp;
>>else if(info>head->data)
>>{
>>insert(head->rchild,info);
>>}
>>else if(infodata)
>>{
>>insert(head->lchild,info);
>>}
>>}
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> --
> Manoj Lalavat
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Recursive Function For insertion in BST

2011-01-15 Thread Logic King
hello all,
i am a beginner to data structures.I have created a recursive function
for insertion of a node in BST,but the function is not working
properly.plz correct me,probably i am doing something wrong with
the pointers
help required :( .urgent !!
the function is here---

void insert(struct node *head,int info)
{
struct node *temp=malloc(sizeof(struct node));
temp->data=info;
temp->rchild=NULL;
temp->lchild=NULL;
if(head==NULL)
head=temp;
else if(info>head->data)
{
insert(head->rchild,info);
}
else if(infodata)
{
insert(head->lchild,info);
}
}

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.