Re: [algogeeks] trees

2010-06-13 Thread Lekha
Inorder traversal till u reach the kth element(If it is sorted in descending
order, otherwise go till (n-k)th element)..


On Sun, Jun 13, 2010 at 9:24 PM, Rohit Saraf wrote:

> Repeated q. Search in the group
>
> --
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Lekha

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

2010-06-13 Thread Rohit Saraf
Repeated q. Search in the group

-- 
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from 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] Cycle in Undirected and Directed Graphs

2010-06-13 Thread Rohit Saraf
In any directed graph just check if dfs has a back edge. For
undirected, check if there is a nontree edge

-- 
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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

2010-06-13 Thread Roshan Mathews
On Sun, Jun 13, 2010 at 18:36, souravsain  wrote:
> Lets keep discussions in t his group limited to Algos and problems
> neutral to any language.
>
Yes, please.

-- 
http://roshan.mathews.in/

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from 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] Cycle in Undirected and Directed Graphs

2010-06-13 Thread sharad kumar
in case of undirected graph we can make use of bfs.in directed graph can
make us of topological sort.

On Mon, Jun 14, 2010 at 2:04 AM, amit  wrote:

> Hi,
> Can anyone explain how to find cycle in undirected graph in O(|v|)
> time and in directed graph in O(|e+v|) time?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
yezhu malai vaasa venkataramana Govinda Govinda

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

2010-06-13 Thread Modeling Expert
@Divya
For (3) : You are getting last line twice because of wrong usage of
feof(fp). Remember , feof() returns true after EOF file is reached and
not when EOF is read.
feof tells you end of file is reached and it can tell that only after
reading EOF and not while reading it !!
So after last line is printed , feof(fp) is still false, and then
program tries to read from file where it fails ( but no one checks
there if fgets(...) fails ) and program prints the old value (i.e.
last line ) . You can cross check this by making str null after every
print and you would see its not last line but the last value stored by
'str' which is printed. You should ideally do !feof(fp) after fgets()
OR use fgets() to check file end by " feof() != NULL OR similar
way.

Hope it helps.




On Jun 13, 8:57 pm, jalaj jaiswal  wrote:
> declaration of fclose in stdio.h is as fclose (FILE*);
> so it has too many arguments...
> On Sun, Jun 13, 2010 at 9:06 PM, divya jain wrote:
>
>
>
> > sorry i pasted wrong questn unser 2..
>
> > the real question is
>
> > which file will get closed through fclose()
> > #include
> > int main()
> > {
> > FILE *fp,*fs,*ft;
> > fp=fopen("a.c","r");
> > fs=fopen("b.c","r");
> > ft=fopen("c.c","r");
> > fclose(fp,fs,ft);
> > return 0;
> > }
>
> > 3. yes it is feof..srry typed it wrong... nd fgets(str,80,fp) is perfectly
> > fine.. now the ans to this questn is that last line of the file will be
> > printed twice...( which i m unable to get why)...plzz explain...
>
> > @ souravsain plzz ignore this mail..srry for the inconvenience..
>
> > On 13 June 2010 17:37, jalaj jaiswal  wrote:
>
> >> in question 1... ch gets the value of EOF... so first kicit 44-a
> >> gokulpeth\0 nagpur will get printed and then the value of EOF..
>
> >>  question number 2 .. seems to me as nrml ...i think myfile.c only gets
> >> closed
>
> >> in question number 3..it shld be fgets(str,79,fp)
>
> >> On Sun, Jun 13, 2010 at 2:49 PM, divya  wrote:
>
> >>> 1. wat ll be the o/p. plz explain y?
> >>> // abc.c contains "kicit 44-a gokulpeth\0 nagpur"
> >>> #include
> >>>  #include
> >>>  int main()
> >>>  {
> >>>  unsigned char ch;
> >>>  FILE *fp;
> >>>  fp=fopen("abc.c","r");
> >>>  if(fp==NULL)
> >>>  {
> >>>  printf("unable to open the file \n");
> >>>  exit(1);
> >>>  }
> >>>  while((ch=getc(fp))!=EOF)
> >>>  printf("%c",ch);
> >>>  fclose(fp);
> >>>  printf("\n",ch);
> >>>  return 0;
> >>>  }
>
> >>>  2.which file will get closed through fclose() in the following
> >>> program and why?
> >>> #include
> >>>          int main()
> >>>  {FILE *fp;
> >>>  char ch;
> >>>  int i=1;
> >>>  fp=fopen(myfile.c","r");
> >>>          while((ch=getc(fp)!=EOF))
> >>>          {
> >>>                  if(ch=='\n')
> >>>                          i++;
> >>>          }
>
> >>>          fclose(fp);
> >>>          return 0;
> >>>  }
>
> >>>  3.point out the error if any in following
>
> >>> #include
> >>>          int main()
> >>>  {
> >>>          FILE *fp;
> >>>          char str[80];
> >>>          fp=fopen("trial","r");
> >>>          while(!eof(fp))
> >>>          {
> >>>                  fgets(str,80,fp);
> >>>                  puts(str);
> >>>          }
> >>>          fclose(fp);
> >>>          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 algoge...@googlegroups.com.
> >>> To unsubscribe from 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,
> >> Jalaj Jaiswal
> >> +919026283397
> >> B.TECH IT
> >> 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 algoge...@googlegroups.com.
> >> To unsubscribe from 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 algoge...@googlegroups.com.
> > To unsubscribe from 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,
> Jalaj Jaiswal
> +919026283397
> B.TECH IT
> 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 algoge...@googlegroups.com.
To unsubscribe from 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: Endian-ness check

2010-06-13 Thread Minotauraus
How about a pointer? :D

On Jun 13, 5:56 am, debajyotisarma  wrote:
> Is it possible to check endianness of a system in C without creating
> variable?
>  i.e. Program should not contain any variable.

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

2010-06-13 Thread Anand
On Sun, Jun 13, 2010 at 4:10 AM, divya jain wrote:

> wat i meant is
> the ans of this questn is
> 10.00 0.00 3 1080263967
> now my questn is y u.f_e is printing 0.00 and similarly y u.l_e is
> giving this value...
>
> @ Divya:
Here 3.55 is stored as a floating point number after converting it to
mantisa and exponent. when you print the hex value of u.l_e you will get the
floating point number in below format. and %ld will print the decimal value
for it.
Hope this is clear.

*Format*

SEEE

EMMM





*Binary*

1101

01001000

 you



*Hex*

C1

48

00

00

http://codepad.org/UuvvUBTO

http://www.fsinc.com/reference/html/com9anm.htm


thanks,

Anand





> On 13 June 2010 15:08, Rohit Saraf  wrote:
>
>> If you are not able to print the long int and that's the prob, you can use
>> %ld instead of %d
>>
>> --
>> Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>>
>> On Sun, Jun 13, 2010 at 1:49 PM, divya jain wrote:
>>
>>> its an o/p questn..
>>> conversion wen ur variable is long..nd u r printing using %f...i dont
>>> know how to perform conversion from float to int long nd vice versa..
>>> pl help
>>>
>>> On 13 June 2010 12:12, Rohit Saraf  wrote:
>>>
 what is this for...
 and which conversion are you talking abt?

 --
 Rohit Saraf
 Second Year Undergraduate,
 Dept. of Computer Science and Engineering
 IIT Bombay
 http://www.cse.iitb.ac.in/~rohitfeb14


 On Sat, Jun 12, 2010 at 11:20 PM, divya wrote:

> #include 
> main()
> {
>  union {
>  long l_e;
>  float f_e;
>  } u;
>
>  long l_v;
>  float f_v;
>  l_v = u.l_e = 10;
>  printf("%f ", (float)l_v);
>  printf("%f ", u.f_e);
>  f_v = u.f_e = 3.555;
>  printf("%d ", (long)f_v);
>  printf("%d ", u.l_e);
> }
> hw to do the conversion here..
>
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
 To unsubscribe from 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 algoge...@googlegroups.com.
>>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from 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: Endian-ness check

2010-06-13 Thread souravsain
Printf("%d",(char)2);
If this print 2 then lsb is 2, else if 0 then msb is 2

On Jun 13, 5:56 pm, debajyotisarma  wrote:
> Is it possible to check endianness of a system in C without creating
> variable?
>  i.e. Program should not contain any variable.

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

2010-06-13 Thread Modeling Expert
@jalaj

Yes , this is endian ness specific. On windows/x86 linux which are
little endian, ch[0] would be lower 8 bits. On solaris/power pc which
are big endian this would be upper 8 bits. e.g.
union a temp;
temp.i = 0x12345678   //! here big end is 0x12 and little end is 0x78
then temp.ch[0] = 78 //! Little end first for little endian

and temp.ch[0] = 0x12 for big endian



On Jun 13, 9:18 pm, jalaj jaiswal  wrote:
> hey i too have a doubt... and its just 1 ... i'll not ask c/c++ again,,,
>
> we have a union a{
>                        int i;
>                        char ch[4];
>                 }
> int here is of 4 bytes.
> i initialise i=512...
> what value will ch[0] get the upper 8 bits or the lower 8 bits... is it big
> endian or little endian dependent... please explain this ??
>
> On Sun, Jun 13, 2010 at 9:43 PM, Rohit Saraf 
> wrote:
>
>
>
> > I agree mass bombarding with such questions is not very good.. but one
> > doesn't join groups and all for getting a few doubts cleared.
> > Anyways, i have no problem with anything. :D
>
> > --
> > Rohit Saraf
> > Second Year Undergraduate,
> > Dept. of Computer Science and Engineering
> > IIT Bombay
> >http://www.cse.iitb.ac.in/~rohitfeb14
>
> > On Sun, Jun 13, 2010 at 9:26 PM, souravsain  wrote:
>
> >> and @rohit you will get better insight into the topic by more expert
> >> people by posting the question in right forum. I guess thats a win-win
> >> situation for one who has the question as he is get to know more and
> >> for people you are interested in going through C++ questions as they
> >> will read views from many more experts :)
>
> >> On Jun 13, 7:31 pm, Rohit Saraf  wrote:
> >> > @Souravsain : Is there any serious problem in this. Anyone can just add
> >> a
> >> > [C++] in the subject and uninterested people can make filters in gmail
> >> :)
>
> >> > --
> >> > Rohit Saraf
> >> > Second Year Undergraduate,
> >> > Dept. of Computer Science and Engineering
> >> > IIT 
> >> > Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14
>
> >> > On Sun, Jun 13, 2010 at 6:35 PM, souravsain 
> >> wrote:
> >> > > @divya
>
> >> > > Lets keep discussions in t his group limited to Algos and problems
> >> > > neutral to any language.
>
> >> > > Request you to post these C++ / C language specific questions to those
> >> > > language specific groups. This will not only help this group remain
> >> > > confined to its core purpose but will help you get better insights to
> >> > > ur problem by language specific geeks there. For C++ I would recommend
> >> > > you to try the group
> >> > >http://groups.google.co.in/group/comp.lang.c++.moderated/topics?hl=en.
>
> >> > > Regards,
> >> > > Sourav
>
> >> > > On Jun 13, 2:29 pm, divya  wrote:
> >> > > > tell the o/p of following with explanations
>
> >> > > > 1. #include
> >> > > > int main()
> >> > > > {
> >> > > >   struct value
> >> > > > {
> >> > > > int bit1:1;
> >> > > > int bit3:4;
> >> > > > int bit4:4;
>
> >> > > > }bit;
>
> >> > > > printf("%d\n",sizeof(bit));
> >> > > > return 0;
>
> >> > > > }
>
> >> > > > 2.
> >> > > > #include
> >> > > > int main()
> >> > > > {
> >> > > > struct value
> >> > > > {
> >> > > > int bit1: 1;
> >> > > > int bit3: 4;
> >> > > > int bit4: 4;} bit={1,2,2};
>
> >> > > > printf("%d %d %d\n",bit.bit1,bit.bit3,bit.bit4);
> >> > > > return 0;
>
> >> > > > }
>
> >> > > > 3 can bit field be used in union??
>
> >> > > --
> >> > > You received this message because you are subscribed to the Google
> >> Groups
> >> > > "Algorithm Geeks" group.
> >> > > To post to this group, send email to algoge...@googlegroups.com.
> >> > > To unsubscribe from this group, send email to
> >> > > algogeeks+unsubscr...@googlegroups.com
> >> 
> >> > > .
> >> > > For more options, visit this group at
> >> > >http://groups.google.com/group/algogeeks?hl=en.-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 algoge...@googlegroups.com.
> >> To unsubscribe from 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 algoge...@googlegroups.com.
> > To unsubscribe from 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,
> Jalaj Jaiswal
> +919026283397
> B.TECH IT
> IIIT ALLAHABAD

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to thi

[algogeeks] Re: file handing

2010-06-13 Thread souravsain
For Problem 3 see section "4.2 Using feof() incorrectly" in
http://www.drpaulcarter.com/cs/common-c-errors.php

On Jun 13, 8:36 pm, divya jain  wrote:
> sorry i pasted wrong questn unser 2..
>
> the real question is
> which file will get closed through fclose()
> #include
> int main()
> {
> FILE *fp,*fs,*ft;
> fp=fopen("a.c","r");
> fs=fopen("b.c","r");
> ft=fopen("c.c","r");
> fclose(fp,fs,ft);
> return 0;
>
> }
>
> 3. yes it is feof..srry typed it wrong... nd fgets(str,80,fp) is perfectly
> fine.. now the ans to this questn is that last line of the file will be
> printed twice...( which i m unable to get why)...plzz explain...
>
> @ souravsain plzz ignore this mail..srry for the inconvenience..
>
> On 13 June 2010 17:37, jalaj jaiswal  wrote:
>
>
>
> > in question 1... ch gets the value of EOF... so first kicit 44-a
> > gokulpeth\0 nagpur will get printed and then the value of EOF..
>
> >  question number 2 .. seems to me as nrml ...i think myfile.c only gets
> > closed
>
> > in question number 3..it shld be fgets(str,79,fp)
>
> > On Sun, Jun 13, 2010 at 2:49 PM, divya  wrote:
>
> >> 1. wat ll be the o/p. plz explain y?
> >> // abc.c contains "kicit 44-a gokulpeth\0 nagpur"
> >> #include
> >>  #include
> >>  int main()
> >>  {
> >>  unsigned char ch;
> >>  FILE *fp;
> >>  fp=fopen("abc.c","r");
> >>  if(fp==NULL)
> >>  {
> >>  printf("unable to open the file \n");
> >>  exit(1);
> >>  }
> >>  while((ch=getc(fp))!=EOF)
> >>  printf("%c",ch);
> >>  fclose(fp);
> >>  printf("\n",ch);
> >>  return 0;
> >>  }
>
> >>  2.which file will get closed through fclose() in the following
> >> program and why?
> >> #include
> >>          int main()
> >>  {FILE *fp;
> >>  char ch;
> >>  int i=1;
> >>  fp=fopen(myfile.c","r");
> >>          while((ch=getc(fp)!=EOF))
> >>          {
> >>                  if(ch=='\n')
> >>                          i++;
> >>          }
>
> >>          fclose(fp);
> >>          return 0;
> >>  }
>
> >>  3.point out the error if any in following
>
> >> #include
> >>          int main()
> >>  {
> >>          FILE *fp;
> >>          char str[80];
> >>          fp=fopen("trial","r");
> >>          while(!eof(fp))
> >>          {
> >>                  fgets(str,80,fp);
> >>                  puts(str);
> >>          }
> >>          fclose(fp);
> >>          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 algoge...@googlegroups.com.
> >> To unsubscribe from 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,
> > Jalaj Jaiswal
> > +919026283397
> > B.TECH IT
> > 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 algoge...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.- 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 algoge...@googlegroups.com.
To unsubscribe from 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] stack

2010-06-13 Thread Jitendra Kushwaha
Stack can be sorted in O(n^2).

@sankalp:
 Stack can always be sorted. Why do you think it cant be in some cases ?

One can think like insertion sort
algo :
1. for i in (1,n)
  2. Pop up the top n-1 element and keep nth element in global variable say
"hold"
  3. while pushing get the position for "hold" and push it there

for loop will take O(n) and step 2 will take take O(n) time. So overall
O(n^2) complexity
Program can be done with recursion using a variable (hence O(1) space). But
it will use system stack :)


Any comments OR better solution is welcomed??

-- 
Regards
Jitendra Kushwaha
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 algoge...@googlegroups.com.
To unsubscribe from 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] trees

2010-06-13 Thread sharad
find k th largest element in bst(inplace)

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from 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] Cycle in Undirected and Directed Graphs

2010-06-13 Thread amit
Hi,
Can anyone explain how to find cycle in undirected graph in O(|v|)
time and in directed graph in O(|e+v|) time?

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

2010-06-13 Thread Minotauraus
Are you missing some constraint here? If it has enough space, you can
just copy elements over and sort them together.
nlogn is as good as it can get for sorting. (Unless you want to get
into sorting networks).


On Jun 12, 9:57 am, sharad  wrote:
> an algorithm to sort two unsorted arrays, the former enough lengthy to
> accomodate all the elements in the latter, in place

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

2010-06-13 Thread ANUJ KUMAR
http://www.spoj.pl/problems/HAN01/
i implemented it using stack but am getting tle someone please help

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

2010-06-13 Thread jalaj jaiswal
give the algorithm for toi if... the a disk can be placed on top the disk
just larger then it and on the ground..

-- 
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
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 algoge...@googlegroups.com.
To unsubscribe from 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 number in an array

2010-06-13 Thread jalaj jaiswal
give an algo to find a unique number in an array

for eg a[]={1,3,4,1,4,5,6,1,5}

here 3 is the unique number as it occur only once... moreover array contains
only 1 unique number



-- 
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
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 algoge...@googlegroups.com.
To unsubscribe from 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] Stack Space for Quick Sort vs Merge Sort.

2010-06-13 Thread amit
Can anyone tell what is Stack Space required for Quick Sort and Merge
Sort.And how in each case it can be modified.

Correct me if I am wrong on this.
Space Complexity of Merge Sort ( Not Inplace) - O(n)
Space Complexity of Quick Sort  - O(1)

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

2010-06-13 Thread Minotauraus
a1a2a3b1b2b3
=> [a1 a2] a3 [b1 b2] b3
=> [a1 a2] [b1 b2] a3 b3
=> a1 a2 b1 b2 a3 b3
=> a1 b1 a2 b2 a3 b3

The algo. that I put forth works. And I think Sourav's will as well.
The grouping needs to be in numbers of 4.
The total number of elements need not.
-Minotauraus.

On Jun 13, 1:46 pm, Pramod Negi  wrote:
> Hello All,
>
> What every algorithm mentioned above have some problem.
>
> The Recursive swapping won’t work if you don’t have 2^n elements.
>
> Same with getting the indexes, it will form a cycle.
>
> Thanks
>
> Pramod Negi
>
> On Fri, Jun 11, 2010 at 7:09 PM, sharad kumar wrote:
>
>
>
> > excellent soln!!
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algoge...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com > .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 algoge...@googlegroups.com.
To unsubscribe from 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

2010-06-13 Thread vadivel selvaraj
@ sharad... DO u mean the former  has got unused space in which the latter
can occupy

On Sun, Jun 13, 2010 at 11:02 AM, harit agarwal wrote:

> sort both arrays separetely and then perform merge operation ..it is
> O(mlogm+nlog)...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Simplicity is prerequisite for reliability.
– Edsger W. Dijkstra

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

2010-06-13 Thread Anand
here is an algo to reverse the nibble in O(n);
http://codepad.org/0NbsP5Td

On Sat, Jun 12, 2010 at 9:05 AM, jalaj jaiswal wrote:

>
> write an algorithm to reverse a nibble in one pass...using bitwise
> operators
> --
> With Regards,
> Jalaj Jaiswal
>
> +919026283397
> B.TECH IT
> 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] file handing

2010-06-13 Thread sharad kumar
for ques 2

Here the file *A.C* alone closed.

To close all streams we have to use *fcloseall()* function

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

2010-06-13 Thread Pramod Negi
Hello All,

What every algorithm mentioned above have some problem.



The Recursive swapping won’t work if you don’t have 2^n elements.

Same with getting the indexes, it will form a cycle.



Thanks

Pramod Negi




On Fri, Jun 11, 2010 at 7:09 PM, sharad kumar wrote:

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

2010-06-13 Thread Pramod Negi
>From last few days I'm seeing the question that is coming here is not
algorithm specific.
Purpose of this group is achieved or defeated???


Thanks
Pramod Negi

On Sun, Jun 13, 2010 at 9:48 PM, jalaj jaiswal wrote:

> hey i too have a doubt... and its just 1 ... i'll not ask c/c++ again,,,
>
> we have a union a{
>int i;
>char ch[4];
> }
> int here is of 4 bytes.
> i initialise i=512...
> what value will ch[0] get the upper 8 bits or the lower 8 bits... is it big
> endian or little endian dependent... please explain this ??
>
>
> On Sun, Jun 13, 2010 at 9:43 PM, Rohit Saraf 
> wrote:
>
>> I agree mass bombarding with such questions is not very good.. but one
>> doesn't join groups and all for getting a few doubts cleared.
>> Anyways, i have no problem with anything. :D
>>
>> --
>> Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>>
>> On Sun, Jun 13, 2010 at 9:26 PM, souravsain  wrote:
>>
>>> and @rohit you will get better insight into the topic by more expert
>>> people by posting the question in right forum. I guess thats a win-win
>>> situation for one who has the question as he is get to know more and
>>> for people you are interested in going through C++ questions as they
>>> will read views from many more experts :)
>>>
>>> On Jun 13, 7:31 pm, Rohit Saraf  wrote:
>>> > @Souravsain : Is there any serious problem in this. Anyone can just add
>>> a
>>> > [C++] in the subject and uninterested people can make filters in gmail
>>> :)
>>> >
>>> > --
>>> > Rohit Saraf
>>> > Second Year Undergraduate,
>>> > Dept. of Computer Science and Engineering
>>> > IIT 
>>> > Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14
>>> >
>>> >
>>> >
>>> > On Sun, Jun 13, 2010 at 6:35 PM, souravsain 
>>> wrote:
>>> > > @divya
>>> >
>>> > > Lets keep discussions in t his group limited to Algos and problems
>>> > > neutral to any language.
>>> >
>>> > > Request you to post these C++ / C language specific questions to
>>> those
>>> > > language specific groups. This will not only help this group remain
>>> > > confined to its core purpose but will help you get better insights to
>>> > > ur problem by language specific geeks there. For C++ I would
>>> recommend
>>> > > you to try the group
>>> > >http://groups.google.co.in/group/comp.lang.c++.moderated/topics?hl=en
>>> .
>>> >
>>> > > Regards,
>>> > > Sourav
>>> >
>>> > > On Jun 13, 2:29 pm, divya  wrote:
>>> > > > tell the o/p of following with explanations
>>> >
>>> > > > 1. #include
>>> > > > int main()
>>> > > > {
>>> > > >   struct value
>>> > > > {
>>> > > > int bit1:1;
>>> > > > int bit3:4;
>>> > > > int bit4:4;
>>> >
>>> > > > }bit;
>>> >
>>> > > > printf("%d\n",sizeof(bit));
>>> > > > return 0;
>>> >
>>> > > > }
>>> >
>>> > > > 2.
>>> > > > #include
>>> > > > int main()
>>> > > > {
>>> > > > struct value
>>> > > > {
>>> > > > int bit1: 1;
>>> > > > int bit3: 4;
>>> > > > int bit4: 4;} bit={1,2,2};
>>> >
>>> > > > printf("%d %d %d\n",bit.bit1,bit.bit3,bit.bit4);
>>> > > > return 0;
>>> >
>>> > > > }
>>> >
>>> > > > 3 can bit field be used in union??
>>> >
>>> > > --
>>> > > You received this message because you are subscribed to the Google
>>> Groups
>>> > > "Algorithm Geeks" group.
>>> > > To post to this group, send email to algoge...@googlegroups.com.
>>> > > To unsubscribe from this group, send email to
>>> > > algogeeks+unsubscr...@googlegroups.com
>>> 
>>> > > .
>>> > > For more options, visit this group at
>>> > >http://groups.google.com/group/algogeeks?hl=en.- 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 algoge...@googlegroups.com.
>>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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,
> Jalaj Jaiswal
> +919026283397
> B.TECH IT
> 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 algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this gro

Re: [algogeeks] Re: bits

2010-06-13 Thread jalaj jaiswal
hey i too have a doubt... and its just 1 ... i'll not ask c/c++ again,,,

we have a union a{
   int i;
   char ch[4];
}
int here is of 4 bytes.
i initialise i=512...
what value will ch[0] get the upper 8 bits or the lower 8 bits... is it big
endian or little endian dependent... please explain this ??

On Sun, Jun 13, 2010 at 9:43 PM, Rohit Saraf wrote:

> I agree mass bombarding with such questions is not very good.. but one
> doesn't join groups and all for getting a few doubts cleared.
> Anyways, i have no problem with anything. :D
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
> On Sun, Jun 13, 2010 at 9:26 PM, souravsain  wrote:
>
>> and @rohit you will get better insight into the topic by more expert
>> people by posting the question in right forum. I guess thats a win-win
>> situation for one who has the question as he is get to know more and
>> for people you are interested in going through C++ questions as they
>> will read views from many more experts :)
>>
>> On Jun 13, 7:31 pm, Rohit Saraf  wrote:
>> > @Souravsain : Is there any serious problem in this. Anyone can just add
>> a
>> > [C++] in the subject and uninterested people can make filters in gmail
>> :)
>> >
>> > --
>> > Rohit Saraf
>> > Second Year Undergraduate,
>> > Dept. of Computer Science and Engineering
>> > IIT 
>> > Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14
>> >
>> >
>> >
>> > On Sun, Jun 13, 2010 at 6:35 PM, souravsain 
>> wrote:
>> > > @divya
>> >
>> > > Lets keep discussions in t his group limited to Algos and problems
>> > > neutral to any language.
>> >
>> > > Request you to post these C++ / C language specific questions to those
>> > > language specific groups. This will not only help this group remain
>> > > confined to its core purpose but will help you get better insights to
>> > > ur problem by language specific geeks there. For C++ I would recommend
>> > > you to try the group
>> > >http://groups.google.co.in/group/comp.lang.c++.moderated/topics?hl=en.
>> >
>> > > Regards,
>> > > Sourav
>> >
>> > > On Jun 13, 2:29 pm, divya  wrote:
>> > > > tell the o/p of following with explanations
>> >
>> > > > 1. #include
>> > > > int main()
>> > > > {
>> > > >   struct value
>> > > > {
>> > > > int bit1:1;
>> > > > int bit3:4;
>> > > > int bit4:4;
>> >
>> > > > }bit;
>> >
>> > > > printf("%d\n",sizeof(bit));
>> > > > return 0;
>> >
>> > > > }
>> >
>> > > > 2.
>> > > > #include
>> > > > int main()
>> > > > {
>> > > > struct value
>> > > > {
>> > > > int bit1: 1;
>> > > > int bit3: 4;
>> > > > int bit4: 4;} bit={1,2,2};
>> >
>> > > > printf("%d %d %d\n",bit.bit1,bit.bit3,bit.bit4);
>> > > > return 0;
>> >
>> > > > }
>> >
>> > > > 3 can bit field be used in union??
>> >
>> > > --
>> > > You received this message because you are subscribed to the Google
>> Groups
>> > > "Algorithm Geeks" group.
>> > > To post to this group, send email to algoge...@googlegroups.com.
>> > > To unsubscribe from this group, send email to
>> > > algogeeks+unsubscr...@googlegroups.com
>> 
>> > > .
>> > > For more options, visit this group at
>> > >http://groups.google.com/group/algogeeks?hl=en.- 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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,
Jalaj Jaiswal
+919026283397
B.TECH IT
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 algoge...@googlegroups.com.
To unsubscribe from 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: bits

2010-06-13 Thread Rohit Saraf
I agree mass bombarding with such questions is not very good.. but one
doesn't join groups and all for getting a few doubts cleared.
Anyways, i have no problem with anything. :D

--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14


On Sun, Jun 13, 2010 at 9:26 PM, souravsain  wrote:

> and @rohit you will get better insight into the topic by more expert
> people by posting the question in right forum. I guess thats a win-win
> situation for one who has the question as he is get to know more and
> for people you are interested in going through C++ questions as they
> will read views from many more experts :)
>
> On Jun 13, 7:31 pm, Rohit Saraf  wrote:
> > @Souravsain : Is there any serious problem in this. Anyone can just add a
> > [C++] in the subject and uninterested people can make filters in gmail :)
> >
> > --
> > Rohit Saraf
> > Second Year Undergraduate,
> > Dept. of Computer Science and Engineering
> > IIT Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14
> >
> >
> >
> > On Sun, Jun 13, 2010 at 6:35 PM, souravsain 
> wrote:
> > > @divya
> >
> > > Lets keep discussions in t his group limited to Algos and problems
> > > neutral to any language.
> >
> > > Request you to post these C++ / C language specific questions to those
> > > language specific groups. This will not only help this group remain
> > > confined to its core purpose but will help you get better insights to
> > > ur problem by language specific geeks there. For C++ I would recommend
> > > you to try the group
> > >http://groups.google.co.in/group/comp.lang.c++.moderated/topics?hl=en.
> >
> > > Regards,
> > > Sourav
> >
> > > On Jun 13, 2:29 pm, divya  wrote:
> > > > tell the o/p of following with explanations
> >
> > > > 1. #include
> > > > int main()
> > > > {
> > > >   struct value
> > > > {
> > > > int bit1:1;
> > > > int bit3:4;
> > > > int bit4:4;
> >
> > > > }bit;
> >
> > > > printf("%d\n",sizeof(bit));
> > > > return 0;
> >
> > > > }
> >
> > > > 2.
> > > > #include
> > > > int main()
> > > > {
> > > > struct value
> > > > {
> > > > int bit1: 1;
> > > > int bit3: 4;
> > > > int bit4: 4;} bit={1,2,2};
> >
> > > > printf("%d %d %d\n",bit.bit1,bit.bit3,bit.bit4);
> > > > return 0;
> >
> > > > }
> >
> > > > 3 can bit field be used in union??
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Algorithm Geeks" group.
> > > To post to this group, send email to algoge...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > algogeeks+unsubscr...@googlegroups.com
> 
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.- 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from 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: bits

2010-06-13 Thread souravsain
and @rohit you will get better insight into the topic by more expert
people by posting the question in right forum. I guess thats a win-win
situation for one who has the question as he is get to know more and
for people you are interested in going through C++ questions as they
will read views from many more experts :)

On Jun 13, 7:31 pm, Rohit Saraf  wrote:
> @Souravsain : Is there any serious problem in this. Anyone can just add a
> [C++] in the subject and uninterested people can make filters in gmail :)
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14
>
>
>
> On Sun, Jun 13, 2010 at 6:35 PM, souravsain  wrote:
> > @divya
>
> > Lets keep discussions in t his group limited to Algos and problems
> > neutral to any language.
>
> > Request you to post these C++ / C language specific questions to those
> > language specific groups. This will not only help this group remain
> > confined to its core purpose but will help you get better insights to
> > ur problem by language specific geeks there. For C++ I would recommend
> > you to try the group
> >http://groups.google.co.in/group/comp.lang.c++.moderated/topics?hl=en.
>
> > Regards,
> > Sourav
>
> > On Jun 13, 2:29 pm, divya  wrote:
> > > tell the o/p of following with explanations
>
> > > 1. #include
> > > int main()
> > > {
> > >   struct value
> > > {
> > > int bit1:1;
> > > int bit3:4;
> > > int bit4:4;
>
> > > }bit;
>
> > > printf("%d\n",sizeof(bit));
> > > return 0;
>
> > > }
>
> > > 2.
> > > #include
> > > int main()
> > > {
> > > struct value
> > > {
> > > int bit1: 1;
> > > int bit3: 4;
> > > int bit4: 4;} bit={1,2,2};
>
> > > printf("%d %d %d\n",bit.bit1,bit.bit3,bit.bit4);
> > > return 0;
>
> > > }
>
> > > 3 can bit field be used in union??
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algoge...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.- 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] file handing

2010-06-13 Thread jalaj jaiswal
declaration of fclose in stdio.h is as fclose (FILE*);
so it has too many arguments...
On Sun, Jun 13, 2010 at 9:06 PM, divya jain wrote:

> sorry i pasted wrong questn unser 2..
>
> the real question is
>
> which file will get closed through fclose()
> #include
> int main()
> {
> FILE *fp,*fs,*ft;
> fp=fopen("a.c","r");
> fs=fopen("b.c","r");
> ft=fopen("c.c","r");
> fclose(fp,fs,ft);
> return 0;
> }
>
> 3. yes it is feof..srry typed it wrong... nd fgets(str,80,fp) is perfectly
> fine.. now the ans to this questn is that last line of the file will be
> printed twice...( which i m unable to get why)...plzz explain...
>
> @ souravsain plzz ignore this mail..srry for the inconvenience..
>
> On 13 June 2010 17:37, jalaj jaiswal  wrote:
>
>> in question 1... ch gets the value of EOF... so first kicit 44-a
>> gokulpeth\0 nagpur will get printed and then the value of EOF..
>>
>>  question number 2 .. seems to me as nrml ...i think myfile.c only gets
>> closed
>>
>> in question number 3..it shld be fgets(str,79,fp)
>>
>>
>> On Sun, Jun 13, 2010 at 2:49 PM, divya  wrote:
>>
>>> 1. wat ll be the o/p. plz explain y?
>>> // abc.c contains "kicit 44-a gokulpeth\0 nagpur"
>>> #include
>>>  #include
>>>  int main()
>>>  {
>>>  unsigned char ch;
>>>  FILE *fp;
>>>  fp=fopen("abc.c","r");
>>>  if(fp==NULL)
>>>  {
>>>  printf("unable to open the file \n");
>>>  exit(1);
>>>  }
>>>  while((ch=getc(fp))!=EOF)
>>>  printf("%c",ch);
>>>  fclose(fp);
>>>  printf("\n",ch);
>>>  return 0;
>>>  }
>>>
>>>  2.which file will get closed through fclose() in the following
>>> program and why?
>>> #include
>>>  int main()
>>>  {FILE *fp;
>>>  char ch;
>>>  int i=1;
>>>  fp=fopen(myfile.c","r");
>>>  while((ch=getc(fp)!=EOF))
>>>  {
>>>  if(ch=='\n')
>>>  i++;
>>>  }
>>>
>>>  fclose(fp);
>>>  return 0;
>>>  }
>>>
>>>  3.point out the error if any in following
>>>
>>> #include
>>>  int main()
>>>  {
>>>  FILE *fp;
>>>  char str[80];
>>>  fp=fopen("trial","r");
>>>  while(!eof(fp))
>>>  {
>>>  fgets(str,80,fp);
>>>  puts(str);
>>>  }
>>>  fclose(fp);
>>>  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 algoge...@googlegroups.com.
>>> To unsubscribe from 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,
>> Jalaj Jaiswal
>> +919026283397
>> B.TECH IT
>> 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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,
Jalaj Jaiswal
+919026283397
B.TECH IT
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 algoge...@googlegroups.com.
To unsubscribe from 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: bits

2010-06-13 Thread souravsain
@rohit: This is not about any serious problem, its about asking ur
self why then make different types of groups. You can also talk about
art and music by adding [art] or [music] in subject or talk about any
topic on earth. The question u need to ask is then why have different
groups. This will answer ur question.

On Jun 13, 7:31 pm, Rohit Saraf  wrote:
> @Souravsain : Is there any serious problem in this. Anyone can just add a
> [C++] in the subject and uninterested people can make filters in gmail :)
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14
>
>
>
> On Sun, Jun 13, 2010 at 6:35 PM, souravsain  wrote:
> > @divya
>
> > Lets keep discussions in t his group limited to Algos and problems
> > neutral to any language.
>
> > Request you to post these C++ / C language specific questions to those
> > language specific groups. This will not only help this group remain
> > confined to its core purpose but will help you get better insights to
> > ur problem by language specific geeks there. For C++ I would recommend
> > you to try the group
> >http://groups.google.co.in/group/comp.lang.c++.moderated/topics?hl=en.
>
> > Regards,
> > Sourav
>
> > On Jun 13, 2:29 pm, divya  wrote:
> > > tell the o/p of following with explanations
>
> > > 1. #include
> > > int main()
> > > {
> > >   struct value
> > > {
> > > int bit1:1;
> > > int bit3:4;
> > > int bit4:4;
>
> > > }bit;
>
> > > printf("%d\n",sizeof(bit));
> > > return 0;
>
> > > }
>
> > > 2.
> > > #include
> > > int main()
> > > {
> > > struct value
> > > {
> > > int bit1: 1;
> > > int bit3: 4;
> > > int bit4: 4;} bit={1,2,2};
>
> > > printf("%d %d %d\n",bit.bit1,bit.bit3,bit.bit4);
> > > return 0;
>
> > > }
>
> > > 3 can bit field be used in union??
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algoge...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.- 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 algoge...@googlegroups.com.
To unsubscribe from 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: Print large Fibonacci numbers

2010-06-13 Thread Modeling Expert
you can also use http://gmplib.org/
-Manish

On Jun 11, 10:12 pm, Raj N  wrote:
> Ya thanks !!
>
> On Fri, Jun 11, 2010 at 10:31 PM, Rohit Saraf
> wrote:
>
> > Fibonacci numbers can be calculated very efficiently
> > using matrix multiplications.
>
> > I hope you can think it/google it now.. that is better  than me writing so
> > much again :)
>
> > --
> > Rohit Saraf
> > Second Year Undergraduate,
> > Dept. of Computer Science and Engineering
> > IIT Bombay
> >http://www.cse.iitb.ac.in/~rohitfeb14
>
> > On Fri, Jun 11, 2010 at 8:12 PM, Raj N  wrote:
>
> >> How to print very large Fibonacci numbers eg fib(1000).
> >> My approach:
> >> When any one of fib(i-1) or fib(i-2) has more than 12 or 13 digits,
> >> partition them into groups of 4 digits and put them in a linked list.
> >> fib(i-1) is put in list1, fib(i-2) in list2. Perform the addition of
> >> these long numbers and overwrite in list2.
> >> Now to find next fib list1 is taken as fib(i-2) and list2 as fib(i-1)
> >> and this repeats until we approach the given number and finally the
> >> result is in list2.
> >> As the number of digits goes on increasing, the list is constructed
> >> dynamically.
>
> >> If anyone has an efficient approach pls tell me.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to algoge...@googlegroups.com.
> >> To unsubscribe from 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 algoge...@googlegroups.com.
> > To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from 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: bits

2010-06-13 Thread divya jain
thanks to all :)
@ souravsain sorry for the inconvenience


On 13 June 2010 20:01, Rohit Saraf  wrote:

> @Souravsain : Is there any serious problem in this. Anyone can just add a
> [C++] in the subject and uninterested people can make filters in gmail :)
>
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
> On Sun, Jun 13, 2010 at 6:35 PM, souravsain  wrote:
>
>> @divya
>>
>> Lets keep discussions in t his group limited to Algos and problems
>> neutral to any language.
>>
>> Request you to post these C++ / C language specific questions to those
>> language specific groups. This will not only help this group remain
>> confined to its core purpose but will help you get better insights to
>> ur problem by language specific geeks there. For C++ I would recommend
>> you to try the group
>> http://groups.google.co.in/group/comp.lang.c++.moderated/topics?hl=en.
>>
>> Regards,
>> Sourav
>>
>> On Jun 13, 2:29 pm, divya  wrote:
>> > tell the o/p of following with explanations
>> >
>> > 1. #include
>> > int main()
>> > {
>> >   struct value
>> > {
>> > int bit1:1;
>> > int bit3:4;
>> > int bit4:4;
>> >
>> > }bit;
>> >
>> > printf("%d\n",sizeof(bit));
>> > return 0;
>> >
>> > }
>> >
>> > 2.
>> > #include
>> > int main()
>> > {
>> > struct value
>> > {
>> > int bit1: 1;
>> > int bit3: 4;
>> > int bit4: 4;} bit={1,2,2};
>> >
>> > printf("%d %d %d\n",bit.bit1,bit.bit3,bit.bit4);
>> > return 0;
>> >
>> > }
>> >
>> > 3 can bit field be used in union??
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] file handing

2010-06-13 Thread divya jain
sorry i pasted wrong questn unser 2..

the real question is
which file will get closed through fclose()
#include
int main()
{
FILE *fp,*fs,*ft;
fp=fopen("a.c","r");
fs=fopen("b.c","r");
ft=fopen("c.c","r");
fclose(fp,fs,ft);
return 0;
}

3. yes it is feof..srry typed it wrong... nd fgets(str,80,fp) is perfectly
fine.. now the ans to this questn is that last line of the file will be
printed twice...( which i m unable to get why)...plzz explain...

@ souravsain plzz ignore this mail..srry for the inconvenience..

On 13 June 2010 17:37, jalaj jaiswal  wrote:

> in question 1... ch gets the value of EOF... so first kicit 44-a
> gokulpeth\0 nagpur will get printed and then the value of EOF..
>
>  question number 2 .. seems to me as nrml ...i think myfile.c only gets
> closed
>
> in question number 3..it shld be fgets(str,79,fp)
>
>
> On Sun, Jun 13, 2010 at 2:49 PM, divya  wrote:
>
>> 1. wat ll be the o/p. plz explain y?
>> // abc.c contains "kicit 44-a gokulpeth\0 nagpur"
>> #include
>>  #include
>>  int main()
>>  {
>>  unsigned char ch;
>>  FILE *fp;
>>  fp=fopen("abc.c","r");
>>  if(fp==NULL)
>>  {
>>  printf("unable to open the file \n");
>>  exit(1);
>>  }
>>  while((ch=getc(fp))!=EOF)
>>  printf("%c",ch);
>>  fclose(fp);
>>  printf("\n",ch);
>>  return 0;
>>  }
>>
>>  2.which file will get closed through fclose() in the following
>> program and why?
>> #include
>>  int main()
>>  {FILE *fp;
>>  char ch;
>>  int i=1;
>>  fp=fopen(myfile.c","r");
>>  while((ch=getc(fp)!=EOF))
>>  {
>>  if(ch=='\n')
>>  i++;
>>  }
>>
>>  fclose(fp);
>>  return 0;
>>  }
>>
>>  3.point out the error if any in following
>>
>> #include
>>  int main()
>>  {
>>  FILE *fp;
>>  char str[80];
>>  fp=fopen("trial","r");
>>  while(!eof(fp))
>>  {
>>  fgets(str,80,fp);
>>  puts(str);
>>  }
>>  fclose(fp);
>>  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 algoge...@googlegroups.com.
>> To unsubscribe from 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,
> Jalaj Jaiswal
> +919026283397
> B.TECH IT
> 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from 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: bits

2010-06-13 Thread Rohit Saraf
@Souravsain : Is there any serious problem in this. Anyone can just add a
[C++] in the subject and uninterested people can make filters in gmail :)


--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14


On Sun, Jun 13, 2010 at 6:35 PM, souravsain  wrote:

> @divya
>
> Lets keep discussions in t his group limited to Algos and problems
> neutral to any language.
>
> Request you to post these C++ / C language specific questions to those
> language specific groups. This will not only help this group remain
> confined to its core purpose but will help you get better insights to
> ur problem by language specific geeks there. For C++ I would recommend
> you to try the group
> http://groups.google.co.in/group/comp.lang.c++.moderated/topics?hl=en.
>
> Regards,
> Sourav
>
> On Jun 13, 2:29 pm, divya  wrote:
> > tell the o/p of following with explanations
> >
> > 1. #include
> > int main()
> > {
> >   struct value
> > {
> > int bit1:1;
> > int bit3:4;
> > int bit4:4;
> >
> > }bit;
> >
> > printf("%d\n",sizeof(bit));
> > return 0;
> >
> > }
> >
> > 2.
> > #include
> > int main()
> > {
> > struct value
> > {
> > int bit1: 1;
> > int bit3: 4;
> > int bit4: 4;} bit={1,2,2};
> >
> > printf("%d %d %d\n",bit.bit1,bit.bit3,bit.bit4);
> > return 0;
> >
> > }
> >
> > 3 can bit field be used in union??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from 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: file handing

2010-06-13 Thread souravsain
Guys

Lets keep discussions in t his group limited to Algos and problems
neutral to any language.

@divya: Request you to post these C++ language specific questions to
those language specific groups. This will not only help this group
remain confined to its core purpose but will help you get better
insights to ur problem by language specific geeks there. For C++ I
would recommend you to try the group
http://groups.google.co.in/group/comp.lang.c++.moderated/topics?hl=en.

Regards,
Sourav

On Jun 13, 5:32 pm, BALARUKESH SIVARAMAN 
wrote:
> For the 1st qn..
> the o/p will print the code in the file and then print an infinite sequence
> of empty spaces. the reason is...
> In C EOF is defined to hold a value -1 which when assigned to unsigned
> becomes 255. So it goes in an unending loop even after encountering the end
> of file.
>
> In second qn..
> the file myfile.c will be closed.
>
> In third qn...
> It is not eof(fp) it is feof(fp) . There is no function eof defined in
> stdio.h. Use the correct function for files

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



Re: [algogeeks] file handing

2010-06-13 Thread jalaj jaiswal
in question 1... ch gets the value of EOF... so first kicit 44-a gokulpeth\0
nagpur will get printed and then the value of EOF..

 question number 2 .. seems to me as nrml ...i think myfile.c only gets
closed

in question number 3..it shld be fgets(str,79,fp)

On Sun, Jun 13, 2010 at 2:49 PM, divya  wrote:

> 1. wat ll be the o/p. plz explain y?
> // abc.c contains "kicit 44-a gokulpeth\0 nagpur"
> #include
>  #include
>  int main()
>  {
>  unsigned char ch;
>  FILE *fp;
>  fp=fopen("abc.c","r");
>  if(fp==NULL)
>  {
>  printf("unable to open the file \n");
>  exit(1);
>  }
>  while((ch=getc(fp))!=EOF)
>  printf("%c",ch);
>  fclose(fp);
>  printf("\n",ch);
>  return 0;
>  }
>
>  2.which file will get closed through fclose() in the following
> program and why?
> #include
>  int main()
>  {FILE *fp;
>  char ch;
>  int i=1;
>  fp=fopen(myfile.c","r");
>  while((ch=getc(fp)!=EOF))
>  {
>  if(ch=='\n')
>  i++;
>  }
>
>  fclose(fp);
>  return 0;
>  }
>
>  3.point out the error if any in following
>
> #include
>  int main()
>  {
>  FILE *fp;
>  char str[80];
>  fp=fopen("trial","r");
>  while(!eof(fp))
>  {
>  fgets(str,80,fp);
>  puts(str);
>  }
>  fclose(fp);
>  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 algoge...@googlegroups.com.
> To unsubscribe from 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,
Jalaj Jaiswal
+919026283397
B.TECH IT
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 algoge...@googlegroups.com.
To unsubscribe from 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: Problem with Virtual Function

2010-06-13 Thread souravsain
Guys

Lets keep discussions in t his group limited to Algos and problems
neutral to any language.
@akshay: Request you to post these C++ language specific questions to
those language specific groups. This will not only help this group
remain confined to its core purpose but will help you get better
insights to ur problem by language specific geeks there. For C++ I
would recommend you to try the group
http://groups.google.co.in/group/comp.lang.c++.moderated/topics?hl=en.

Regards,
Sourav

On Jun 13, 5:08 pm, BALARUKESH SIVARAMAN 
wrote:
> In the first post the problem was that m_speed is not public also u should
> access m_speed using Scope resolution operator as m_speed is not a member of
> B.
> class A
> {
> public:
> virtual int speed()=0;
> int m_speed;};
>
> class B:public A
> {
> public:
> int speed()
> {
> return A::m_speed;}
> };
>
> For ur second question...
>
> int main()
> {
> A *aptr=new B;
> cout return 0;
>
> }
>
> I hope ur not clear with the concept of virtual functions... This example
> will help you. If not post back ur questions...

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

2010-06-13 Thread jalaj jaiswal
hmm... for question number 1.. .. u can understand more easliy with the
following examlple


#include
// 1. #include
#pragma pack(1)
struct value
{
int a;
int bit3: 4;
int bit4: 4;

};
#pragma pack()
int main()
{
struct value bit;

printf("%d",sizeof(bit));
 system("pause");
 return 0;
 }
here size is 40 bits.(take int of 4 bytes).. so 5 bytes... if you don't use
pragma directives... compiler assignes location as multiple of 4 for fast
processing.. google it you'll find



for question number 2:

all your structure elements are signed so bit 1 cannot take any int value as
it has got only 1 bit.. so if you declare bit1 as unsigned
you will get fine output.. in bit3 and bit4 ..you will get fine answer if
value from(0 to 7)

i hope you got it

for question number 3;
ya you can use bit fields in union..


On Sun, Jun 13, 2010 at 2:59 PM, divya  wrote:

> tell the o/p of following with explanations
>
> 1. #include
> int main()
> {
>  struct value
> {
> int bit1:1;
> int bit3:4;
> int bit4:4;
> }bit;
>
> printf("%d\n",sizeof(bit));
> return 0;
> }
>
> 2.
> #include
> int main()
> {
> struct value
> {
> int bit1: 1;
> int bit3: 4;
> int bit4: 4;
> } bit={1,2,2};
> printf("%d %d %d\n",bit.bit1,bit.bit3,bit.bit4);
> return 0;
> }
>
> 3 can bit field be used in union??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from 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,
Jalaj Jaiswal
+919026283397
B.TECH IT
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 algoge...@googlegroups.com.
To unsubscribe from 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: bits

2010-06-13 Thread souravsain
@divya

Lets keep discussions in t his group limited to Algos and problems
neutral to any language.

Request you to post these C++ / C language specific questions to those
language specific groups. This will not only help this group remain
confined to its core purpose but will help you get better insights to
ur problem by language specific geeks there. For C++ I would recommend
you to try the group 
http://groups.google.co.in/group/comp.lang.c++.moderated/topics?hl=en.

Regards,
Sourav

On Jun 13, 2:29 pm, divya  wrote:
> tell the o/p of following with explanations
>
> 1. #include
> int main()
> {
>   struct value
> {
> int bit1:1;
> int bit3:4;
> int bit4:4;
>
> }bit;
>
> printf("%d\n",sizeof(bit));
> return 0;
>
> }
>
> 2.
> #include
> int main()
> {
> struct value
> {
> int bit1: 1;
> int bit3: 4;
> int bit4: 4;} bit={1,2,2};
>
> printf("%d %d %d\n",bit.bit1,bit.bit3,bit.bit4);
> return 0;
>
> }
>
> 3 can bit field be used in union??

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

2010-06-13 Thread souravsain
Guys

Lets keep discussions in t his group limited to Algos and problems
neutral to any language.
@divya: Request you to post these C++ language specific questions to
those language specific groups. This will not only help this group
remain confined to its core purpose but will help you get better
insights to ur problem by language specific geeks there. For C++ I
would recommend you to try the group
http://groups.google.co.in/group/comp.lang.c++.moderated/topics?hl=en.

Regards,
Sourav

On Jun 13, 4:10 pm, divya jain  wrote:
> wat i meant is
> the ans of this questn is
> 10.00 0.00 3 1080263967
> now my questn is y u.f_e is printing 0.00 and similarly y u.l_e is
> giving this value...
> On 13 June 2010 15:08, Rohit Saraf  wrote:
>
>
>
> > If you are not able to print the long int and that's the prob, you can use
> > %ld instead of %d
>
> > --
> > Rohit Saraf
> > Second Year Undergraduate,
> > Dept. of Computer Science and Engineering
> > IIT Bombay
> >http://www.cse.iitb.ac.in/~rohitfeb14
>
> > On Sun, Jun 13, 2010 at 1:49 PM, divya jain wrote:
>
> >> its an o/p questn..
> >> conversion wen ur variable is long..nd u r printing using %f...i dont know
> >> how to perform conversion from float to int long nd vice versa..
> >> pl help
>
> >> On 13 June 2010 12:12, Rohit Saraf  wrote:
>
> >>> what is this for...
> >>> and which conversion are you talking abt?
>
> >>> --
> >>> Rohit Saraf
> >>> Second Year Undergraduate,
> >>> Dept. of Computer Science and Engineering
> >>> IIT Bombay
> >>>http://www.cse.iitb.ac.in/~rohitfeb14
>
> >>> On Sat, Jun 12, 2010 at 11:20 PM, divya wrote:
>
>  #include 
>  main()
>  {
>   union {
>   long l_e;
>   float f_e;
>   } u;
>
>   long l_v;
>   float f_v;
>   l_v = u.l_e = 10;
>   printf("%f ", (float)l_v);
>   printf("%f ", u.f_e);
>   f_v = u.f_e = 3.555;
>   printf("%d ", (long)f_v);
>   printf("%d ", u.l_e);
>  }
>  hw to do the conversion here..
>
>  --
>  You received this message because you are subscribed to the Google
>  Groups "Algorithm Geeks" group.
>  To post to this group, send email to algoge...@googlegroups.com.
>  To unsubscribe from 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 algoge...@googlegroups.com.
> >>> To unsubscribe from 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 algoge...@googlegroups.com.
> >> To unsubscribe from 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 algoge...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.- 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 algoge...@googlegroups.com.
To unsubscribe from 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] Endian-ness check

2010-06-13 Thread debajyotisarma
Is it possible to check endianness of a system in C without creating
variable?
 i.e. Program should not contain any variable.

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

2010-06-13 Thread Debajyoti Sarma
1.
i think if the total no of bits is within  no of bits in a int , the
size will b same as int .

here total bits 3 < 32 (bits in int according to gcc, in Turbo c its 16)
so size of structure will be 4(in gcc), 2 (in TC)

if total no of bits is 40 (suppose) than size will be 8(in GCC) , 4(in TC)



2.
By default int is considered as signed int
if in n bits signed int is stored than the range will be -2^(n-1) to 2^(n-1)-1
so for bit1:1 range is -1,0
so for bit2:4 range is -8,7
so for bit3:4 range is -8,7
if the assigned value exceed than it will rotate as per conversion
from unsigned to signed int (hope u know this)
bit1 cant hold 1 .it ll store as -1
others within range
so it ll output as -1 4 4


3.
Yea u can have 3 bitfields in union ...but u can initilize only one at a time

her sizeof union will be always sizeof int bcoz u can use only one
variable at a time in union
and u cant declare bitfield of more than bits of an int (u wil be
compile time error)



On 6/13/10, divya  wrote:
> tell the o/p of following with explanations
>
> 1. #include
> int main()
> {
>   struct value
> {
> int bit1:1;
> int bit3:4;
> int bit4:4;
> }bit;
>
> printf("%d\n",sizeof(bit));
> return 0;
> }
>
> 2.
> #include
> int main()
> {
> struct value
> {
> int bit1: 1;
> int bit3: 4;
> int bit4: 4;
> } bit={1,2,2};
> printf("%d %d %d\n",bit.bit1,bit.bit3,bit.bit4);
> return 0;
> }
>
> 3 can bit field be used in union??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] file handing

2010-06-13 Thread BALARUKESH SIVARAMAN
For the 1st qn..
the o/p will print the code in the file and then print an infinite sequence
of empty spaces. the reason is...
In C EOF is defined to hold a value -1 which when assigned to unsigned
becomes 255. So it goes in an unending loop even after encountering the end
of file.

In second qn..
the file myfile.c will be closed.

In third qn...
It is not eof(fp) it is feof(fp) . There is no function eof defined in
stdio.h. Use the correct function for files

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

2010-06-13 Thread BALARUKESH SIVARAMAN
In the first post the problem was that m_speed is not public also u should
access m_speed using Scope resolution operator as m_speed is not a member of
B.
class A
{
public:
virtual int speed()=0;
int m_speed;
};
class B:public A
{
public:
int speed()
{
return A::m_speed;
}
};
For ur second question...

int main()
{
A *aptr=new B;
cout

[algogeeks] file handing

2010-06-13 Thread divya
1. wat ll be the o/p. plz explain y?
// abc.c contains "kicit 44-a gokulpeth\0 nagpur"
#include
  #include
  int main()
  {
  unsigned char ch;
  FILE *fp;
  fp=fopen("abc.c","r");
  if(fp==NULL)
  {
  printf("unable to open the file \n");
  exit(1);
  }
  while((ch=getc(fp))!=EOF)
  printf("%c",ch);
  fclose(fp);
  printf("\n",ch);
  return 0;
  }

  2.which file will get closed through fclose() in the following
program and why?
#include
  int main()
  {FILE *fp;
  char ch;
  int i=1;
  fp=fopen(myfile.c","r");
  while((ch=getc(fp)!=EOF))
  {
  if(ch=='\n')
  i++;
  }

  fclose(fp);
  return 0;
  }

  3.point out the error if any in following

#include
  int main()
  {
  FILE *fp;
  char str[80];
  fp=fopen("trial","r");
  while(!eof(fp))
  {
  fgets(str,80,fp);
  puts(str);
  }
  fclose(fp);
  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 algoge...@googlegroups.com.
To unsubscribe from 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] bits

2010-06-13 Thread divya
tell the o/p of following with explanations

1. #include
int main()
{
  struct value
{
int bit1:1;
int bit3:4;
int bit4:4;
}bit;

printf("%d\n",sizeof(bit));
return 0;
}

2.
#include
int main()
{
struct value
{
int bit1: 1;
int bit3: 4;
int bit4: 4;
} bit={1,2,2};
printf("%d %d %d\n",bit.bit1,bit.bit3,bit.bit4);
return 0;
}

3 can bit field be used in union??

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

2010-06-13 Thread divya jain
wat i meant is
the ans of this questn is
10.00 0.00 3 1080263967
now my questn is y u.f_e is printing 0.00 and similarly y u.l_e is
giving this value...
On 13 June 2010 15:08, Rohit Saraf  wrote:

> If you are not able to print the long int and that's the prob, you can use
> %ld instead of %d
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
> On Sun, Jun 13, 2010 at 1:49 PM, divya jain wrote:
>
>> its an o/p questn..
>> conversion wen ur variable is long..nd u r printing using %f...i dont know
>> how to perform conversion from float to int long nd vice versa..
>> pl help
>>
>> On 13 June 2010 12:12, Rohit Saraf  wrote:
>>
>>> what is this for...
>>> and which conversion are you talking abt?
>>>
>>> --
>>> Rohit Saraf
>>> Second Year Undergraduate,
>>> Dept. of Computer Science and Engineering
>>> IIT Bombay
>>> http://www.cse.iitb.ac.in/~rohitfeb14
>>>
>>>
>>> On Sat, Jun 12, 2010 at 11:20 PM, divya wrote:
>>>
 #include 
 main()
 {
  union {
  long l_e;
  float f_e;
  } u;

  long l_v;
  float f_v;
  l_v = u.l_e = 10;
  printf("%f ", (float)l_v);
  printf("%f ", u.f_e);
  f_v = u.f_e = 3.555;
  printf("%d ", (long)f_v);
  printf("%d ", u.l_e);
 }
 hw to do the conversion here..

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



Re: [algogeeks] c- pointers

2010-06-13 Thread divya jain
oh yes..
wen ll i stop making this stupid mistakes :(

On 13 June 2010 15:03, Rohit Saraf  wrote:

> @jalaj: exactly...
> so you(@divya) are right. Sharad's ans was right but logic wasn't.
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
> On Sun, Jun 13, 2010 at 2:35 PM, jalaj jaiswal 
> wrote:
>
>> actually when you subtract two pointers ... its get divided by the size of
>> the variable type its point two...
>> for example.. if you do .. p+1... where let say p is 200 and points to an
>> int type variable then p+1 is 202...(assuming int is of size 2)
>> so (p+1)-p..i.e 202-200 is 1 and not 2
>>
>>
>>
>>
>>
>>
>> On Sun, Jun 13, 2010 at 1:46 PM, divya jain wrote:
>>
>>> bt the ans that sharad gave is ryt..
>>> acc to me 1st row n 1st col of o/p shd b 2 (if size of int is 2) bt it is
>>> 1...
>>>
>>>
>>> On 13 June 2010 12:10, Rohit Saraf  wrote:
>>>
 @divya: u r rite.. that * should not be there

 --
 Rohit Saraf
 Second Year Undergraduate,
 Dept. of Computer Science and Engineering
 IIT Bombay
 http://www.cse.iitb.ac.in/~rohitfeb14


 On Sun, Jun 13, 2010 at 11:07 AM, divya jain 
 wrote:

> ptr is a pointer naaa...then why ptr-p=*(&(arr+1)-&arr)  ???
> why not &(arr+1)-&arr ??
> i knw m wrong somewhr...plz correct me
>
>
> On 13 June 2010 07:57, Mahesh_JNU  wrote:
>
>> agreed .
>>
>>
>> On Sun, Jun 13, 2010 at 7:48 AM, sharad kumar <
>> aryansmit3...@gmail.com> wrote:
>>
>>> 111
>>> 222
>>> 333
>>> 344
>>> ptr++ ->u do posst increment
>>> hence it goes to 1
>>> ptr-p=*(&(arr+1)-&arr)=1
>>> llrly for other cases
>>> when u do *ptr++ due to operator precedence ptr++ is done and then
>>> dereferenced.
>>> hence u get 222
>>> next *++ptr
>>> the ptr is incremented after dereferencing hence u get 333
>>> next ++*ptr here the value t ptr s incrementas it is treated
>>> as++(*ptr) hence u get 3 but others refer to location hence 44
>>>
>>>
>>> On Sat, Jun 12, 2010 at 9:21 PM, divya wrote:
>>>
 #include
 int main()
 {
 static int arr[]={0,1,2,3,4};
 int *p[]={arr,arr+1,arr+2,arr+3,arr+4};
 int **ptr=p;
 ptr++;
 printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
 *ptr++;
 printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
 *++ptr;
 printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
 ++*ptr;
 printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
 return 0;
 }
 wat shd b the o/p n why...

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


>>>
>>>
>>> --
>>> yezhu malai vaasa venkataramana Govinda Govinda
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>>   Mahesh Giri
>>  MCA Final Sem
>> JNU, New Delhi
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
 To unsubscribe from this group, 

Re: [algogeeks] c array

2010-06-13 Thread sankalp srivastava
don't ever use a TC compiler , the most obsolete and mad compiler of all .
Every compiler tries to fix the bug in ur code by some way or the other
using some .Even gcc has a lot of bugs , in the sense it will return an exit
status even if returning a void , but this is on ubuntu and haven't tries
mingW yet . Any

On Sun, Jun 13, 2010 at 1:47 PM, divya jain wrote:

> i use tc
>
>
> On 13 June 2010 13:11, ram  wrote:
>
>> @rohit bro
>>
>> http://www.mingw.org/
>>
>> *MinGW*, a contraction of "Minimalist GNU for Windows", is a port of the
>> GNU Compiler Collection (GCC), and GNU Binutils, for use in the development
>> of native Microsoft Windows applications.
>>
>>
>>
>>
>>
>> *From:* algogeeks@googlegroups.com [mailto:algoge...@googlegroups.com] *On
>> Behalf Of *Rohit Saraf
>> *Sent:* 13 June 2010 08:19
>>
>> *To:* algogeeks@googlegroups.com
>> *Subject:* Re: [algogeeks] c array
>>
>>
>>
>> @ram : i guess you have used some longer string and not "strings"
>>
>>
>>
>> btw..  what is Mingw ?
>>
>> gcc/g++ is not mingw, i guess
>>
>>
>> --
>> Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>> On Sun, Jun 13, 2010 at 8:13 AM, ram  wrote:
>>
>> D:\code\samplecode\main.cpp|5|error: initializer-string for array of chars
>> is too long|
>>
>>
>>
>> I get this error on gcc (Mingw) .
>>
>>
>>
>> Though the array indexing starts from 0.
>>
>> The length specified in char str[7] is always straightforward . in this
>> case char str[7]  . the length of str is seven not eight ;hence the error
>>
>> --
>>
>> ram
>>
>>
>>
>> *From:* algogeeks@googlegroups.com [mailto:algoge...@googlegroups.com] *On
>> Behalf Of *sharad kumar
>> *Sent:* 13 June 2010 07:59
>> *To:* algogeeks@googlegroups.com
>> *Subject:* Re: [algogeeks] c array
>>
>>
>>
>> hey array indexing starts from 0 rite??
>> then y shld u get overflow in first place..
>> s t  r  i n g s \0
>> 0 1 2 3 4 5 6 7
>>
>> On Sat, Jun 12, 2010 at 9:14 PM, divya  wrote:
>>
>> #include
>> int main()
>> {
>>
>> char str[7]="strings";
>> printf("%s\n",str);
>> return 0;
>> }
>>
>> here i m nt getting overflow error whereas if i write stringss instead
>> of strings then there is overflow error.. isnt null stored after s in
>> strings nd 1st case shd also give overflow???
>>
>> --
>>
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>>
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>>
>>
>> --
>> yezhu malai vaasa venkataramana Govinda Govinda
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit 

Re: [algogeeks] union- c

2010-06-13 Thread Anurag Sharma
Check the floating point representation(IEEE 754 format) in variables. There
are specific number of bits in a float variable to represent exponent,
mantissa etc.

Anurag Sharma


On Sun, Jun 13, 2010 at 1:19 PM, divya jain wrote:

> its an o/p questn..
> conversion wen ur variable is long..nd u r printing using %f...i dont know
> how to perform conversion from float to int long nd vice versa..
> pl help
>
>
> On 13 June 2010 12:12, Rohit Saraf  wrote:
>
>> what is this for...
>> and which conversion are you talking abt?
>>
>> --
>> Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>>
>> On Sat, Jun 12, 2010 at 11:20 PM, divya  wrote:
>>
>>> #include 
>>> main()
>>> {
>>>  union {
>>>  long l_e;
>>>  float f_e;
>>>  } u;
>>>
>>>  long l_v;
>>>  float f_v;
>>>  l_v = u.l_e = 10;
>>>  printf("%f ", (float)l_v);
>>>  printf("%f ", u.f_e);
>>>  f_v = u.f_e = 3.555;
>>>  printf("%d ", (long)f_v);
>>>  printf("%d ", u.l_e);
>>> }
>>> hw to do the conversion here..
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from 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] Mirroring Binary Tree Pattern Problem

2010-06-13 Thread BALARUKESH SIVARAMAN
try this one..
make a level order traversal and store the elements in array... on the other
system reconstruct it using right element for the left and left element for
the right...

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

2010-06-13 Thread Rohit Saraf
If you are not able to print the long int and that's the prob, you can use
%ld instead of %d
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14


On Sun, Jun 13, 2010 at 1:49 PM, divya jain wrote:

> its an o/p questn..
> conversion wen ur variable is long..nd u r printing using %f...i dont know
> how to perform conversion from float to int long nd vice versa..
> pl help
>
> On 13 June 2010 12:12, Rohit Saraf  wrote:
>
>> what is this for...
>> and which conversion are you talking abt?
>>
>> --
>> Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>>
>> On Sat, Jun 12, 2010 at 11:20 PM, divya  wrote:
>>
>>> #include 
>>> main()
>>> {
>>>  union {
>>>  long l_e;
>>>  float f_e;
>>>  } u;
>>>
>>>  long l_v;
>>>  float f_v;
>>>  l_v = u.l_e = 10;
>>>  printf("%f ", (float)l_v);
>>>  printf("%f ", u.f_e);
>>>  f_v = u.f_e = 3.555;
>>>  printf("%d ", (long)f_v);
>>>  printf("%d ", u.l_e);
>>> }
>>> hw to do the conversion here..
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c- pointers

2010-06-13 Thread Rohit Saraf
@jalaj: exactly...
so you(@divya) are right. Sharad's ans was right but logic wasn't.

--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14


On Sun, Jun 13, 2010 at 2:35 PM, jalaj jaiswal wrote:

> actually when you subtract two pointers ... its get divided by the size of
> the variable type its point two...
> for example.. if you do .. p+1... where let say p is 200 and points to an
> int type variable then p+1 is 202...(assuming int is of size 2)
> so (p+1)-p..i.e 202-200 is 1 and not 2
>
>
>
>
>
>
> On Sun, Jun 13, 2010 at 1:46 PM, divya jain wrote:
>
>> bt the ans that sharad gave is ryt..
>> acc to me 1st row n 1st col of o/p shd b 2 (if size of int is 2) bt it is
>> 1...
>>
>>
>> On 13 June 2010 12:10, Rohit Saraf  wrote:
>>
>>> @divya: u r rite.. that * should not be there
>>>
>>> --
>>> Rohit Saraf
>>> Second Year Undergraduate,
>>> Dept. of Computer Science and Engineering
>>> IIT Bombay
>>> http://www.cse.iitb.ac.in/~rohitfeb14
>>>
>>>
>>> On Sun, Jun 13, 2010 at 11:07 AM, divya jain 
>>> wrote:
>>>
 ptr is a pointer naaa...then why ptr-p=*(&(arr+1)-&arr)  ???
 why not &(arr+1)-&arr ??
 i knw m wrong somewhr...plz correct me


 On 13 June 2010 07:57, Mahesh_JNU  wrote:

> agreed .
>
>
> On Sun, Jun 13, 2010 at 7:48 AM, sharad kumar  > wrote:
>
>> 111
>> 222
>> 333
>> 344
>> ptr++ ->u do posst increment
>> hence it goes to 1
>> ptr-p=*(&(arr+1)-&arr)=1
>> llrly for other cases
>> when u do *ptr++ due to operator precedence ptr++ is done and then
>> dereferenced.
>> hence u get 222
>> next *++ptr
>> the ptr is incremented after dereferencing hence u get 333
>> next ++*ptr here the value t ptr s incrementas it is treated
>> as++(*ptr) hence u get 3 but others refer to location hence 44
>>
>>
>> On Sat, Jun 12, 2010 at 9:21 PM, divya wrote:
>>
>>> #include
>>> int main()
>>> {
>>> static int arr[]={0,1,2,3,4};
>>> int *p[]={arr,arr+1,arr+2,arr+3,arr+4};
>>> int **ptr=p;
>>> ptr++;
>>> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
>>> *ptr++;
>>> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
>>> *++ptr;
>>> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
>>> ++*ptr;
>>> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
>>> return 0;
>>> }
>>> wat shd b the o/p n why...
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> yezhu malai vaasa venkataramana Govinda Govinda
>>
>>  --
>> You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
>   Mahesh Giri
>  MCA Final Sem
> JNU, New Delhi
>
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
 To unsubscribe from 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 algoge...@googlegroups.com.
>>> To unsubscribe from 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 algoge...@googlegro

Re: [algogeeks] c array

2010-06-13 Thread Rohit Saraf
@ram : oh.. that cygwin thing.. why don't you use pure gcc then... why use
minimalistic one?

@divya: isn't it obsolete yet? Did not see anyone using it after I started
using a computer :D.
 Do you use it because your prof's force you. If not try g++/gcc. That is
the standard & the best compiler today.

--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14


On Sun, Jun 13, 2010 at 1:47 PM, divya jain wrote:

> i use tc
>
>
> On 13 June 2010 13:11, ram  wrote:
>
>> @rohit bro
>>
>> http://www.mingw.org/
>>
>> *MinGW*, a contraction of "Minimalist GNU for Windows", is a port of the
>> GNU Compiler Collection (GCC), and GNU Binutils, for use in the development
>> of native Microsoft Windows applications.
>>
>>
>>
>>
>>
>> *From:* algogeeks@googlegroups.com [mailto:algoge...@googlegroups.com] *On
>> Behalf Of *Rohit Saraf
>> *Sent:* 13 June 2010 08:19
>>
>> *To:* algogeeks@googlegroups.com
>> *Subject:* Re: [algogeeks] c array
>>
>>
>>
>> @ram : i guess you have used some longer string and not "strings"
>>
>>
>>
>> btw..  what is Mingw ?
>>
>> gcc/g++ is not mingw, i guess
>>
>>
>> --
>> Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>> On Sun, Jun 13, 2010 at 8:13 AM, ram  wrote:
>>
>> D:\code\samplecode\main.cpp|5|error: initializer-string for array of chars
>> is too long|
>>
>>
>>
>> I get this error on gcc (Mingw) .
>>
>>
>>
>> Though the array indexing starts from 0.
>>
>> The length specified in char str[7] is always straightforward . in this
>> case char str[7]  . the length of str is seven not eight ;hence the error
>>
>> --
>>
>> ram
>>
>>
>>
>> *From:* algogeeks@googlegroups.com [mailto:algoge...@googlegroups.com] *On
>> Behalf Of *sharad kumar
>> *Sent:* 13 June 2010 07:59
>> *To:* algogeeks@googlegroups.com
>> *Subject:* Re: [algogeeks] c array
>>
>>
>>
>> hey array indexing starts from 0 rite??
>> then y shld u get overflow in first place..
>> s t  r  i n g s \0
>> 0 1 2 3 4 5 6 7
>>
>> On Sat, Jun 12, 2010 at 9:14 PM, divya  wrote:
>>
>> #include
>> int main()
>> {
>>
>> char str[7]="strings";
>> printf("%s\n",str);
>> return 0;
>> }
>>
>> here i m nt getting overflow error whereas if i write stringss instead
>> of strings then there is overflow error.. isnt null stored after s in
>> strings nd 1st case shd also give overflow???
>>
>> --
>>
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>>
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>>
>>
>> --
>> yezhu malai vaasa venkataramana Govinda Govinda
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 

Re: [algogeeks] stack

2010-06-13 Thread sankalp srivastava
it's not always possible to sort a stack in all the cases , consider the
stack 2143 and one tries to sort it feeding the elements in order , we have
now whatever popping technique we use , we cannot have a 1234 kind of
stack in order .The maximum number of permutations we can have with a stack
is 2nCn -2nCn-1 which does not necessarily include the permutated group . In
general , we can pop the elements in a decreasing order in the same order as
they are entered . Try sortin the stack with an input of 4132 .now possible


On Sun, Jun 13, 2010 at 1:57 PM, jaladhi dave wrote:

> what do you mean by sorting elements in stack  ? A stack is a data
> structure in which the relative position of elements depend on their order
> of insertion.
>
> If we sort elements in stack, how does it retain the property of a stack ?
>
> If we really want that property, we will have O(n) rather than O(1) insert
> and maintain two pointers. Stack next and sorted next.
>
>
> On Sun, Jun 13, 2010 at 1:05 PM, jalaj jaiswal 
> wrote:
>
>> how to sort elements of stack using constant space
>>
>> --
>> With Regards,
>>
>> +919026283397
>> B.TECH IT
>> 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from 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] nibbles

2010-06-13 Thread sankalp srivastava
this can be done using the same code as of Sharad above , the only
difference being the mask bits , we mask  four bits of a nibble by the
anding with 0001 , 0010 , 0101 and 1000 .. now , we feed these into the
given number .I mean all the bits as below ..
Suppose we have a nibble as 1100 and we want it to be 0011 , so after
masking , we have the four bits as 1000 , 0100 ,  and  respectively
.We feed the given bits in a reverse order into a nibble (or a character for
that matter ) in a reverse order .
So first bit(1000) is shifted right 3 times and added to result , second
shifted 1 times and added , third shifted 1 time but to the left and fourth
3 times to the left . we add all of the to have the answer  .

On Sun, Jun 13, 2010 at 1:56 PM, jalaj jaiswal wrote:

> can any one explain it using an example...
> let say my nibble is 0100... i have to print 0010... in one go using
> bitwise operators...
> please explain through example
>
> @ sharad ... your code is to swap two nibbles in a character
>
>
> On Sun, Jun 13, 2010 at 1:39 PM, jaladhi dave wrote:
>
>> Write a c-macro to use assembly swap opcode.
>>
>> On Sat, Jun 12, 2010 at 9:35 PM, jalaj jaiswal > > wrote:
>>
>>>
>>> write an algorithm to reverse a nibble in one pass...using bitwise
>>> operators
>>> --
>>> With Regards,
>>> Jalaj Jaiswal
>>> +919026283397
>>> B.TECH IT
>>> 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 algoge...@googlegroups.com.
>>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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,
> Jalaj Jaiswal
> +919026283397
> B.TECH IT
> 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c- pointers

2010-06-13 Thread jalaj jaiswal
actually when you subtract two pointers ... its get divided by the size of
the variable type its point two...
for example.. if you do .. p+1... where let say p is 200 and points to an
int type variable then p+1 is 202...(assuming int is of size 2)
so (p+1)-p..i.e 202-200 is 1 and not 2





On Sun, Jun 13, 2010 at 1:46 PM, divya jain wrote:

> bt the ans that sharad gave is ryt..
> acc to me 1st row n 1st col of o/p shd b 2 (if size of int is 2) bt it is
> 1...
>
>
> On 13 June 2010 12:10, Rohit Saraf  wrote:
>
>> @divya: u r rite.. that * should not be there
>>
>> --
>> Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>>
>> On Sun, Jun 13, 2010 at 11:07 AM, divya jain wrote:
>>
>>> ptr is a pointer naaa...then why ptr-p=*(&(arr+1)-&arr)  ???
>>> why not &(arr+1)-&arr ??
>>> i knw m wrong somewhr...plz correct me
>>>
>>>
>>> On 13 June 2010 07:57, Mahesh_JNU  wrote:
>>>
 agreed .


 On Sun, Jun 13, 2010 at 7:48 AM, sharad kumar 
 wrote:

> 111
> 222
> 333
> 344
> ptr++ ->u do posst increment
> hence it goes to 1
> ptr-p=*(&(arr+1)-&arr)=1
> llrly for other cases
> when u do *ptr++ due to operator precedence ptr++ is done and then
> dereferenced.
> hence u get 222
> next *++ptr
> the ptr is incremented after dereferencing hence u get 333
> next ++*ptr here the value t ptr s incrementas it is treated as++(*ptr)
> hence u get 3 but others refer to location hence 44
>
>
> On Sat, Jun 12, 2010 at 9:21 PM, divya wrote:
>
>> #include
>> int main()
>> {
>> static int arr[]={0,1,2,3,4};
>> int *p[]={arr,arr+1,arr+2,arr+3,arr+4};
>> int **ptr=p;
>> ptr++;
>> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
>> *ptr++;
>> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
>> *++ptr;
>> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
>> ++*ptr;
>> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
>> return 0;
>> }
>> wat shd b the o/p n why...
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> yezhu malai vaasa venkataramana Govinda Govinda
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



 --
   Mahesh Giri
  MCA Final Sem
 JNU, New Delhi

 --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from 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 algoge...@googlegroups.com.
>>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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,
Jalaj Jaiswal
+919026283397
B.TECH IT
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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algog

Re: [algogeeks] stack

2010-06-13 Thread jaladhi dave
what do you mean by sorting elements in stack  ? A stack is a data structure
in which the relative position of elements depend on their order of
insertion.

If we sort elements in stack, how does it retain the property of a stack ?

If we really want that property, we will have O(n) rather than O(1) insert
and maintain two pointers. Stack next and sorted next.

On Sun, Jun 13, 2010 at 1:05 PM, jalaj jaiswal wrote:

> how to sort elements of stack using constant space
>
> --
> With Regards,
> Jalaj Jaiswal
> +919026283397
> B.TECH IT
> 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from 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] nibbles

2010-06-13 Thread jalaj jaiswal
can any one explain it using an example...
let say my nibble is 0100... i have to print 0010... in one go using bitwise
operators...
please explain through example

@ sharad ... your code is to swap two nibbles in a character

On Sun, Jun 13, 2010 at 1:39 PM, jaladhi dave wrote:

> Write a c-macro to use assembly swap opcode.
>
> On Sat, Jun 12, 2010 at 9:35 PM, jalaj jaiswal 
> wrote:
>
>>
>> write an algorithm to reverse a nibble in one pass...using bitwise
>> operators
>> --
>> With Regards,
>> Jalaj Jaiswal
>> +919026283397
>> B.TECH IT
>> 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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,
Jalaj Jaiswal
+919026283397
B.TECH IT
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 algoge...@googlegroups.com.
To unsubscribe from 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] union- c

2010-06-13 Thread divya jain
its an o/p questn..
conversion wen ur variable is long..nd u r printing using %f...i dont know
how to perform conversion from float to int long nd vice versa..
pl help

On 13 June 2010 12:12, Rohit Saraf  wrote:

> what is this for...
> and which conversion are you talking abt?
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
> On Sat, Jun 12, 2010 at 11:20 PM, divya  wrote:
>
>> #include 
>> main()
>> {
>>  union {
>>  long l_e;
>>  float f_e;
>>  } u;
>>
>>  long l_v;
>>  float f_v;
>>  l_v = u.l_e = 10;
>>  printf("%f ", (float)l_v);
>>  printf("%f ", u.f_e);
>>  f_v = u.f_e = 3.555;
>>  printf("%d ", (long)f_v);
>>  printf("%d ", u.l_e);
>> }
>> hw to do the conversion here..
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c array

2010-06-13 Thread divya jain
i use tc

On 13 June 2010 13:11, ram  wrote:

> @rohit bro
>
> http://www.mingw.org/
>
> *MinGW*, a contraction of "Minimalist GNU for Windows", is a port of the
> GNU Compiler Collection (GCC), and GNU Binutils, for use in the development
> of native Microsoft Windows applications.
>
>
>
>
>
> *From:* algogeeks@googlegroups.com [mailto:algoge...@googlegroups.com] *On
> Behalf Of *Rohit Saraf
> *Sent:* 13 June 2010 08:19
>
> *To:* algogeeks@googlegroups.com
> *Subject:* Re: [algogeeks] c array
>
>
>
> @ram : i guess you have used some longer string and not "strings"
>
>
>
> btw..  what is Mingw ?
>
> gcc/g++ is not mingw, i guess
>
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
> On Sun, Jun 13, 2010 at 8:13 AM, ram  wrote:
>
> D:\code\samplecode\main.cpp|5|error: initializer-string for array of chars
> is too long|
>
>
>
> I get this error on gcc (Mingw) .
>
>
>
> Though the array indexing starts from 0.
>
> The length specified in char str[7] is always straightforward . in this
> case char str[7]  . the length of str is seven not eight ;hence the error
>
> --
>
> ram
>
>
>
> *From:* algogeeks@googlegroups.com [mailto:algoge...@googlegroups.com] *On
> Behalf Of *sharad kumar
> *Sent:* 13 June 2010 07:59
> *To:* algogeeks@googlegroups.com
> *Subject:* Re: [algogeeks] c array
>
>
>
> hey array indexing starts from 0 rite??
> then y shld u get overflow in first place..
> s t  r  i n g s \0
> 0 1 2 3 4 5 6 7
>
> On Sat, Jun 12, 2010 at 9:14 PM, divya  wrote:
>
> #include
> int main()
> {
>
> char str[7]="strings";
> printf("%s\n",str);
> return 0;
> }
>
> here i m nt getting overflow error whereas if i write stringss instead
> of strings then there is overflow error.. isnt null stored after s in
> strings nd 1st case shd also give overflow???
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
>
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
>
>
> --
> yezhu malai vaasa venkataramana Govinda Govinda
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c- pointers

2010-06-13 Thread divya jain
bt the ans that sharad gave is ryt..
acc to me 1st row n 1st col of o/p shd b 2 (if size of int is 2) bt it is
1...

On 13 June 2010 12:10, Rohit Saraf  wrote:

> @divya: u r rite.. that * should not be there
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
> On Sun, Jun 13, 2010 at 11:07 AM, divya jain wrote:
>
>> ptr is a pointer naaa...then why ptr-p=*(&(arr+1)-&arr)  ???
>> why not &(arr+1)-&arr ??
>> i knw m wrong somewhr...plz correct me
>>
>>
>> On 13 June 2010 07:57, Mahesh_JNU  wrote:
>>
>>> agreed .
>>>
>>>
>>> On Sun, Jun 13, 2010 at 7:48 AM, sharad kumar 
>>> wrote:
>>>
 111
 222
 333
 344
 ptr++ ->u do posst increment
 hence it goes to 1
 ptr-p=*(&(arr+1)-&arr)=1
 llrly for other cases
 when u do *ptr++ due to operator precedence ptr++ is done and then
 dereferenced.
 hence u get 222
 next *++ptr
 the ptr is incremented after dereferencing hence u get 333
 next ++*ptr here the value t ptr s incrementas it is treated as++(*ptr)
 hence u get 3 but others refer to location hence 44


 On Sat, Jun 12, 2010 at 9:21 PM, divya wrote:

> #include
> int main()
> {
> static int arr[]={0,1,2,3,4};
> int *p[]={arr,arr+1,arr+2,arr+3,arr+4};
> int **ptr=p;
> ptr++;
> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
> *ptr++;
> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
> *++ptr;
> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
> ++*ptr;
> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr);
> return 0;
> }
> wat shd b the o/p n why...
>
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


 --
 yezhu malai vaasa venkataramana Govinda Govinda

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

>>>
>>>
>>>
>>> --
>>>   Mahesh Giri
>>>  MCA Final Sem
>>> JNU, New Delhi
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from 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] stack

2010-06-13 Thread jalaj jaiswal
how to sort elements of stack using constant space

-- 
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
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 algoge...@googlegroups.com.
To unsubscribe from 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: identify the recurring part for a given decimal no

2010-06-13 Thread jaladhi dave
Won't we require to check recurring till at-least two complete iterations of
recurrence pattern.
Also what's the division logic are we going to use ?

In all modern day processor systems, we are likely to have a math
co/sub-processor which will efficiently crunch numbers and round them off to
our desire.

Another way to look at this problem is by considering the no as sequence of
digit and can apply any substring algorithm to find recurrence with better
efficiency.

My 2 Paise.  :)

On Sat, Jun 12, 2010 at 8:07 PM, Anurag Sharma wrote:

> Since we are given numerator 'n' and denominator 'd' separately already.
> and considering n and d as integers and d!=0 we can safely assume n/d as
> either a terminating fraction or a non terminating but recurring fraction,
> in which case we have to find the recurring digits of the fraction.
>
> Now what I suggested was almost same as Ravi's approach.
> take a Set 'S' keeping tuples (R,Q) where R is the current remainder and Q
> is the factor such that d*Q is subtracted from the number to get R.
> In other words. if at an intermediate step of division we have 'a' as the
> divident left then Q=floor(a/d) and R=a%d
>
> Keep dividing 'n' by 'd' like it is done manually. After every division
> check-
> 1. If the current remainder is not present in 'S' then add current
> remainder 'R' and corresponding quotient 'Q' in the set
> 2. If R is found in the set S, then all the following entries in the set
> until end will constitute the recurring digits.
> taking Ravi's example:-
>
> Example:
>   7) 9 (1.*285714*28S=[]
>7
>--
> 20   S=[(2,2)]
>  14
>  ---
>60S=[(2,2), (6,8)]
> 56
>  ---
>   40 S=[(2,2), (6,8),
> (4,5)]
>   35
>   ---
>  50  S=[(2,2), (6,8),
> (4,5), (5,7)]
>   49
>---
>  10  S=[(2,2), (6,8),
> (4,5), (5,7), (1,1)]
> 7
>  
>  30  S=[(2,2), (6,8),
> (4,5), (5,7), (1,1), (3,4)]
>   28   ^
>      |
>   20 2 is found in S here,
> so recurring digits are "285714"
>14
>
>   
>60
> 56
>  repeats
>
>
> hope its clear
>
>
> Anurag Sharma
>
>
>
> On Sat, Jun 12, 2010 at 4:02 PM, divya jain wrote:
>
>> @anurag
>>
>> i dint get ur approach..which numerator n denominator u r talking
>> about..plz explain.. thanks in advance
>>
>> On 11 June 2010 08:57, Anurag Sharma  wrote:
>>
>>> Please note that the fractional repeating part is recurring. and so that
>>> 4th temporary variable assignment will be this way->
>>> temp=x*1 - x= 233456.34563456...  - 23.34563456 = 233433.0  (
>>> mark the fractional part is 0 now since the infinitely repeating 3456...
>>> will get cancelled)
>>> In this  case you can say that 4 places are repeating. But yes its
>>> according to the maths and in any programming language whenever you divide
>>> the numerator and denominator you wont get this infinitely recurring decimal
>>> places.
>>>
>>> @divya, also your approach wont work if the recurring fractional digits
>>> start after few places from the decimal like in the case of
>>> 23.123345634563456  (note here after the decimal place 123 is not
>>> repeating while 3456.. after this 123 is repeating.)
>>>
>>> What I suggest in this case is keep dividing the numerator by denominator
>>> and at every step keep inserting the tupple (remainder, quotient) of that
>>> division step in a set. and before inserting in the set check whether it
>>> already exists. If yes then the all the quotients following from that point
>>> (including the point) will be recurring.
>>>
>>> Regards,
>>>
>>> Anurag Sharma
>>>
>>>
>>>
>>> On Thu, Jun 10, 2010 at 8:25 AM, Veer Sharma 
>>> wrote:
>>>
 Seems it wont work...
 x=23.34563456

 temp = x*100 -x = 233.4563456 - 23.34563456 = 210.11071104
 temp = x*100 -x = 2334.563456 - 23.34563456 = 2311.21782144
 temp = x*1000 -x =  23345.63456 - 23.34563456 = 23322.28892544
 temp = x*1 -x =  233456.3456 - 23.34563456 = 233432.6544
 temp = x*10 -x = 2334563.456 - 23.34563456 = 2334540.11036544

 ...

 On Jun 9, 11:24 pm, Anurag Sharma  wrote:
 > multiply the original number x=23.34563456
 >
 > Anurag Sharma
 >
 > On Wed, Jun 9, 2010 at 10:36 PM, Veer Sharma <
 thisisv...@rediffmail.com>wrote:
 >
 >
 >
 > >

Re: [algogeeks] Mirroring Binary Tree Pattern Problem

2010-06-13 Thread jaladhi dave
what is a virtualization concept ???


I am a newbie regarding the Algo Analysis. I was asked this question
> recently in an interview. Please let me know if anyone of you know how to
> solve this.
>
> *Question:*
> Assume You have a binary Tree (not sorted and not BST) with a specific
> pattern on a Desktop1. How can this same binary Tree has be to mirrored to
> another desktop?
>
> *My Approach:*
> 1. Traverse the binary tree and store the elements in an array. Transfer
> the same to another process present on another desktop through socket
> communication. But in this case how do i construct the same binary tree at
> the other end? Do i read in one of the in-order/post-order/pre-order and do
> it the same way at the other end?
> 2. Does this involve Virtualization concept?
>
> Regards,
> Vikas J
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from 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] nibbles

2010-06-13 Thread jaladhi dave
Write a c-macro to use assembly swap opcode.

On Sat, Jun 12, 2010 at 9:35 PM, jalaj jaiswal wrote:

>
> write an algorithm to reverse a nibble in one pass...using bitwise
> operators
> --
> With Regards,
> Jalaj Jaiswal
> +919026283397
> B.TECH IT
> 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



RE: [algogeeks] c array

2010-06-13 Thread ram
@rohit bro

http://www.mingw.org/

MinGW, a contraction of "Minimalist GNU for Windows", is a port of the GNU
Compiler Collection (GCC), and GNU Binutils, for use in the development of
native Microsoft Windows applications.

 

 

From: algogeeks@googlegroups.com [mailto:algoge...@googlegroups.com] On
Behalf Of Rohit Saraf
Sent: 13 June 2010 08:19
To: algogeeks@googlegroups.com
Subject: Re: [algogeeks] c array

 

@ram : i guess you have used some longer string and not "strings"

 

btw..  what is Mingw ?

gcc/g++ is not mingw, i guess


--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14



On Sun, Jun 13, 2010 at 8:13 AM, ram  wrote:

D:\code\samplecode\main.cpp|5|error: initializer-string for array of chars
is too long|

 

I get this error on gcc (Mingw) .

 

Though the array indexing starts from 0. 

The length specified in char str[7] is always straightforward . in this case
char str[7]  . the length of str is seven not eight ;hence the error

--

ram

 

From: algogeeks@googlegroups.com [mailto:algoge...@googlegroups.com] On
Behalf Of sharad kumar
Sent: 13 June 2010 07:59
To: algogeeks@googlegroups.com
Subject: Re: [algogeeks] c array

 

hey array indexing starts from 0 rite??
then y shld u get overflow in first place..
s t  r  i n g s \0
0 1 2 3 4 5 6 7

On Sat, Jun 12, 2010 at 9:14 PM, divya  wrote:

#include
int main()
{

char str[7]="strings";
printf("%s\n",str);
return 0;
}

here i m nt getting overflow error whereas if i write stringss instead
of strings then there is overflow error.. isnt null stored after s in
strings nd 1st case shd also give overflow???

--

You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.

To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com
 .
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.




-- 
yezhu malai vaasa venkataramana Govinda Govinda

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

2010-06-13 Thread Rohit Saraf
Put the function speed or its declaration inside the class b. Did u forget that?

-- 
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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

2010-06-13 Thread akshay khatri
It gives this error:
error: prototype for ‘int B::speed()’ does not match any in class ‘B’.

Should I include this in class B(in B.h)
class B:public A
{
public:
virtual int speed(); //wouldn't this override the speed() from A ?
private:
int m_speed();
}

class A (in A.h)is defined as this
class A
{
public:
virtual int speed();
}

Another Question:
If I want to use speed() from class B via an object of class A, how can I do
this ?
(in a third file which has: #include) or is there a better way to do
this ?


On 13 June 2010 12:54, Rohit Saraf  wrote:

> yes.. it should... make sure your virtual function is either public or
> protected but not private.
> and if it doesn't can u tell me the error?
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
> On Sun, Jun 13, 2010 at 12:47 PM, akshay khatri  > wrote:
>
>> I meant this:
>> let me explain it like this.
>> I have *virtual int speed()* in class A.(in file A.h)
>> I inherited class in class B(in file B.h) as class B:public A
>> class B have a private member m_speed.
>> Now I have to return m_speed from speed() from class B as I would
>> instantiate an object of class B to use it.
>> So if write my prgram like this:
>>
>> class B:public A
>> {
>> private:
>> int m_speed();
>> }
>>
>> int B::speed()
>> {
>> return m_speed;
>> }
>>
>> would it work ?
>>
>>
>>
>> On 13 June 2010 12:37, Rohit Saraf  wrote:
>>
>>> Make those functions public
>>> And even if M_speed is public of another class, it is still it another
>>> class, you cannot just address it like m_speed in other classes.
>>> Does it help?
>>>
>>> --
>>> Rohit Saraf
>>> Second Year Undergraduate,
>>> Dept. of Computer Science and Engineering
>>> IIT Bombay
>>> http://www.cse.iitb.ac.in/~rohitfeb14
>>>
>>>
>>> On Sun, Jun 13, 2010 at 12:31 PM, akshay khatri <
>>> akshaykhatri...@gmail.com> wrote:
>>>
 Hi

 On 13 June 2010 12:26, Rohit Saraf  wrote:

> M-speed is private and you cannot call it from outside myPlugin.
> (though i did not understand what u wanted to say)
> Can you write ur prob explicitly?
>

 I want to use speed() and direction() defined in myPlugin.h in
 otherPlugin.cpp. How can I use it(syntax) ? If I try to return a variable
 such as m_speed(even if defined in public part of class otherPlugin) , it
 gives an error.



> --
>  Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
>
> On Sun, Jun 13, 2010 at 12:20 PM, akshay khatri <
> akshaykhatri...@gmail.com> wrote:
>
>> I have the following code structure
>> in my file myPlugin.h , i have defined this
>>
>>virtual int speed();
>>
>> and gave a dummy implementation in myPlugin.cpp
>>
>> In another file otherPlugin.h I have included this line:
>>
>>#include 
>>private:
>>int m_speed;
>>
>> also class otherPlugin inherits myPlugin (public scope)
>> I want to redefine speed in otherPlugin.cpp
>> How should I return a value fromspeed() in it ?
>>
>>  int myPlugin::speed()
>>{
>>   return m_speed;
>>}
>> or
>>int otherPlugin::speed()
>>{
>>  return m_speed;
>>}
>>
>> or anything else ?
>>
>> The error I get is that: m_speed was not declared in this scope.
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
 To unsubscribe from 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
>>> "Algo

Re: [algogeeks] Problem with Virtual Function

2010-06-13 Thread Rohit Saraf
yes.. it should... make sure your virtual function is either public or
protected but not private.
and if it doesn't can u tell me the error?
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14


On Sun, Jun 13, 2010 at 12:47 PM, akshay khatri
wrote:

> I meant this:
> let me explain it like this.
> I have *virtual int speed()* in class A.(in file A.h)
> I inherited class in class B(in file B.h) as class B:public A
> class B have a private member m_speed.
> Now I have to return m_speed from speed() from class B as I would
> instantiate an object of class B to use it.
> So if write my prgram like this:
>
> class B:public A
> {
> private:
> int m_speed();
> }
>
> int B::speed()
> {
> return m_speed;
> }
>
> would it work ?
>
>
>
> On 13 June 2010 12:37, Rohit Saraf  wrote:
>
>> Make those functions public
>> And even if M_speed is public of another class, it is still it another
>> class, you cannot just address it like m_speed in other classes.
>> Does it help?
>>
>> --
>> Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>>
>> On Sun, Jun 13, 2010 at 12:31 PM, akshay khatri <
>> akshaykhatri...@gmail.com> wrote:
>>
>>> Hi
>>>
>>> On 13 June 2010 12:26, Rohit Saraf  wrote:
>>>
 M-speed is private and you cannot call it from outside myPlugin. (though
 i did not understand what u wanted to say)
 Can you write ur prob explicitly?

>>>
>>> I want to use speed() and direction() defined in myPlugin.h in
>>> otherPlugin.cpp. How can I use it(syntax) ? If I try to return a variable
>>> such as m_speed(even if defined in public part of class otherPlugin) , it
>>> gives an error.
>>>
>>>
>>>
 --
  Rohit Saraf
 Second Year Undergraduate,
 Dept. of Computer Science and Engineering
 IIT Bombay
 http://www.cse.iitb.ac.in/~rohitfeb14



 On Sun, Jun 13, 2010 at 12:20 PM, akshay khatri <
 akshaykhatri...@gmail.com> wrote:

> I have the following code structure
> in my file myPlugin.h , i have defined this
>
>virtual int speed();
>
> and gave a dummy implementation in myPlugin.cpp
>
> In another file otherPlugin.h I have included this line:
>
>#include 
>private:
>int m_speed;
>
> also class otherPlugin inherits myPlugin (public scope)
> I want to redefine speed in otherPlugin.cpp
> How should I return a value fromspeed() in it ?
>
>  int myPlugin::speed()
>{
>   return m_speed;
>}
> or
>int otherPlugin::speed()
>{
>  return m_speed;
>}
>
> or anything else ?
>
> The error I get is that: m_speed was not declared in this scope.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
 To unsubscribe from 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 algoge...@googlegroups.com.
>>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 Group

Re: [algogeeks] Problem with Virtual Function

2010-06-13 Thread akshay khatri
I meant this:
let me explain it like this.
I have *virtual int speed()* in class A.(in file A.h)
I inherited class in class B(in file B.h) as class B:public A
class B have a private member m_speed.
Now I have to return m_speed from speed() from class B as I would
instantiate an object of class B to use it.
So if write my prgram like this:

class B:public A
{
private:
int m_speed();
}

int B::speed()
{
return m_speed;
}

would it work ?



On 13 June 2010 12:37, Rohit Saraf  wrote:

> Make those functions public
> And even if M_speed is public of another class, it is still it another
> class, you cannot just address it like m_speed in other classes.
> Does it help?
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
> On Sun, Jun 13, 2010 at 12:31 PM, akshay khatri  > wrote:
>
>> Hi
>>
>> On 13 June 2010 12:26, Rohit Saraf  wrote:
>>
>>> M-speed is private and you cannot call it from outside myPlugin. (though
>>> i did not understand what u wanted to say)
>>> Can you write ur prob explicitly?
>>>
>>
>> I want to use speed() and direction() defined in myPlugin.h in
>> otherPlugin.cpp. How can I use it(syntax) ? If I try to return a variable
>> such as m_speed(even if defined in public part of class otherPlugin) , it
>> gives an error.
>>
>>
>>
>>> --
>>>  Rohit Saraf
>>> Second Year Undergraduate,
>>> Dept. of Computer Science and Engineering
>>> IIT Bombay
>>> http://www.cse.iitb.ac.in/~rohitfeb14
>>>
>>>
>>>
>>> On Sun, Jun 13, 2010 at 12:20 PM, akshay khatri <
>>> akshaykhatri...@gmail.com> wrote:
>>>
 I have the following code structure
 in my file myPlugin.h , i have defined this

virtual int speed();

 and gave a dummy implementation in myPlugin.cpp

 In another file otherPlugin.h I have included this line:

#include 
private:
int m_speed;

 also class otherPlugin inherits myPlugin (public scope)
 I want to redefine speed in otherPlugin.cpp
 How should I return a value fromspeed() in it ?

  int myPlugin::speed()
{
   return m_speed;
}
 or
int otherPlugin::speed()
{
  return m_speed;
}

 or anything else ?

 The error I get is that: m_speed was not declared in this scope.

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

2010-06-13 Thread Rohit Saraf
Make those functions public
And even if M_speed is public of another class, it is still it another
class, you cannot just address it like m_speed in other classes.
Does it help?
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14


On Sun, Jun 13, 2010 at 12:31 PM, akshay khatri
wrote:

> Hi
>
> On 13 June 2010 12:26, Rohit Saraf  wrote:
>
>> M-speed is private and you cannot call it from outside myPlugin. (though i
>> did not understand what u wanted to say)
>> Can you write ur prob explicitly?
>>
>
> I want to use speed() and direction() defined in myPlugin.h in
> otherPlugin.cpp. How can I use it(syntax) ? If I try to return a variable
> such as m_speed(even if defined in public part of class otherPlugin) , it
> gives an error.
>
>
>
>> --
>>  Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>>
>>
>> On Sun, Jun 13, 2010 at 12:20 PM, akshay khatri <
>> akshaykhatri...@gmail.com> wrote:
>>
>>> I have the following code structure
>>> in my file myPlugin.h , i have defined this
>>>
>>>virtual int speed();
>>>
>>> and gave a dummy implementation in myPlugin.cpp
>>>
>>> In another file otherPlugin.h I have included this line:
>>>
>>>#include 
>>>private:
>>>int m_speed;
>>>
>>> also class otherPlugin inherits myPlugin (public scope)
>>> I want to redefine speed in otherPlugin.cpp
>>> How should I return a value fromspeed() in it ?
>>>
>>>  int myPlugin::speed()
>>>{
>>>   return m_speed;
>>>}
>>> or
>>>int otherPlugin::speed()
>>>{
>>>  return m_speed;
>>>}
>>>
>>> or anything else ?
>>>
>>> The error I get is that: m_speed was not declared in this scope.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from 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 algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from 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] Problem with Virtual Function

2010-06-13 Thread akshay khatri
Hi

On 13 June 2010 12:26, Rohit Saraf  wrote:

> M-speed is private and you cannot call it from outside myPlugin. (though i
> did not understand what u wanted to say)
> Can you write ur prob explicitly?
>

I want to use speed() and direction() defined in myPlugin.h in
otherPlugin.cpp. How can I use it(syntax) ? If I try to return a variable
such as m_speed(even if defined in public part of class otherPlugin) , it
gives an error.



> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
>
> On Sun, Jun 13, 2010 at 12:20 PM, akshay khatri  > wrote:
>
>> I have the following code structure
>> in my file myPlugin.h , i have defined this
>>
>>virtual int speed();
>>
>> and gave a dummy implementation in myPlugin.cpp
>>
>> In another file otherPlugin.h I have included this line:
>>
>>#include 
>>private:
>>int m_speed;
>>
>> also class otherPlugin inherits myPlugin (public scope)
>> I want to redefine speed in otherPlugin.cpp
>> How should I return a value fromspeed() in it ?
>>
>>  int myPlugin::speed()
>>{
>>   return m_speed;
>>}
>> or
>>int otherPlugin::speed()
>>{
>>  return m_speed;
>>}
>>
>> or anything else ?
>>
>> The error I get is that: m_speed was not declared in this scope.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from 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 algoge...@googlegroups.com.
> To unsubscribe from 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.