[algogeeks] What is the complexity of this program?

2011-09-28 Thread Avenged

Please tell me the *time* and *space* complexity of this program? I believe 
it should be : O(*n*) and O(*1*) respectively. 

#include
#include
#define SET_BIT(x,k) (x|=(1<<(k)))
#define CHECK_BIT(x,k) (x&(1<<(k)))
int main()
{
unsigned int i,ascii;
int count1=0,count2=0;
const char* str = "geekszforgeeks";
for(i=0;ihttps://groups.google.com/d/msg/algogeeks/-/RBLnRACm8HwJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] First non-repeated character complexity?

2011-09-28 Thread Avenged
It's the same code which was posted earlier. Could you explain how to implement 
using bitset?

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/_X21NZy9kZkJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] First non-repeated character complexity?

2011-09-28 Thread Avenged
Bump. Anybody?

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/on-DbSKUdzsJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] First non-repeated character complexity?

2011-09-27 Thread Avenged
Right so the complexity is O(n) Time and O(1) space. Could you tell how to 
check the repeatedness of the character using 1 bit at a time?

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/bHxk_odaPlkJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] First non-repeated character complexity?

2011-09-27 Thread Avenged
could you please provide a working code please ?? this question was asked by 
MS a month back in our college.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/y1O61E41DW4J.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] output

2011-08-12 Thread Avenged
this is the question :

#include
#define prn(a) printf("%d",a)
#define print(a,b,c) prn(a), prn(b), prn(c)
#define max(a,b) (a>b?a:b)

int main()
{
int x=1, y=2;
print(max(x++,y),x,y);
print(max(x++,y),x,y);
return 0;
}

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



Re: [algogeeks]

2011-08-11 Thread Avenged
Like he said earlier , its a compiler implementation.

On Aug 12, 12:55 am, aditi garg  wrote:
> @sagar: why doesnt it take place sequentially like 4*5*6*7??
> why do the frst two increments take place like dat??
>
>
>
>
>
>
>
>
>
> On Fri, Aug 12, 2011 at 1:19 AM, sagar pareek  wrote:
> > told u before
> > in turbo c it increments all values of x
> > x=3;
> > c=7*7*7*7;
> > c=2401
>
> > On Fri, Aug 12, 2011 at 1:16 AM, Puneet Chawla 
> > wrote:
>
> >> In turbo it is showing o/p 2401 again still confused...
>
> >> On Fri, Aug 12, 2011 at 1:14 AM, sagar pareek wrote:
>
> >>> ok if we have the scenario like u stated then it will be done in gcc as
> >>> :-
> >>> x=3;
> >>> c=5*5*(++x)*(++x);
> >>> c=25*6*(++x);
> >>> c=150*7;
> >>> c=1050;
>
> >>> On Fri, Aug 12, 2011 at 1:10 AM, aditi garg 
> >>> wrote:
>
>  @sagar: bt i dint understand how is it done
>  what if we had something like (++x)*(++x)*(++x)*(++x) thn how wud it be
>  evaluated in gcc?
>  and since it is giving diff ans on diff compilers that is wat i mean by
>  being undefined...
>
>  On Fri, Aug 12, 2011 at 1:05 AM, Puneet Chawla <
>  puneetchawla...@gmail.com> wrote:
>
> > @Aditi i thnk sagar parteek is right ...in turbo compiler it's
> > incrementing and finally max of all values and multiply the value means 
> > pre
> > increment->evaluate->postincrement
>
> > On Fri, Aug 12, 2011 at 1:02 AM, sagar pareek 
> > wrote:
>
> >> well its always depends on compiler to compiler
> >> in turbo c it will first increment all x
> >> results in
> >> c=6*6*6
> >> c=216
>
> >> but in gcc it will be as explained by me above
>
> >> On Fri, Aug 12, 2011 at 12:56 AM, aditi garg <
> >> aditi.garg.6...@gmail.com> wrote:
>
> >>> i think it wud be undefined...the value is getting modified more than
> >>> once and hence violating the sequence points rule...plz corect me if 
> >>> im
> >>> wrong...
>
> >>> On Fri, Aug 12, 2011 at 12:48 AM, Puneet Chawla <
> >>> puneetchawla...@gmail.com> wrote:
>
>  In turbo compiler it's o/p is 216 and in dev it's 150..
>  Help me out..
>
>  On Fri, Aug 12, 2011 at 12:45 AM, sagar pareek <
>  sagarpar...@gmail.com> wrote:
>
> > after expansion of macro
> > it will be c=(++x)*(++x)*(++x);
>
> > now it be solved as
> >  c= 5*5*(++x);
> > c=25*6;
> > c=150
>
> > On Fri, Aug 12, 2011 at 12:38 AM, Puneet Chawla <
> > puneetchawla...@gmail.com> wrote:
>
> >> #define cube(x) (x)*(x)*(x)
> >> main()
> >> {
> >>     int x=3,c;
> >>     c=cube(++x);
> >>     printf("%d",c);
>
> >> return 0;
> >> }
>
> >> will anyone please tell me why o/p is 150.?
>
> >> --
> >> With regards
> >>   
> >> Puneet Chawla
>
> >>  --
> >> You received this message because you are subscribed to the Google
> >> Groups "Algorithm Geeks" group.
> >> To post to this group, send email to algogeeks@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> algogeeks+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >>http://groups.google.com/group/algogeeks?hl=en.
>
> > --
> > **Regards
> > SAGAR PAREEK
> > COMPUTER SCIENCE AND ENGINEERING
> > NIT ALLAHABAD
>
> >  --
> > You received this message because you are subscribed to the Google
> > Groups "Algorithm Geeks" group.
> > To post to this group, send email to algogeeks@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.
>
>  --
>  With regards
>    
>  Puneet Chawla
>  Computer Engineering Student
>  NIT Kurukshetra
>
>   --
>  You received this message because you are subscribed to the Google
>  Groups "Algorithm Geeks" group.
>  To post to this group, send email to algogeeks@googlegroups.com.
>  To unsubscribe from this group, send email to
>  algogeeks+unsubscr...@googlegroups.com.
>  For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
> >>> --
> >>> Aditi Garg
> >>> Undergraduate Student
> >>> Electronics & Communication Divison
> >>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
> >>> Sector 3, Dwarka
> >>> New Delhi
>
> >>>  --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "Algorithm Geeks" group.
> >>> To post to this group, send email to algogeeks@googlegroups.com.
> >>> To unsubscribe from this group, sen

[algogeeks] Re:

2011-08-10 Thread Avenged
It's an UNDEFINED BEHAVIOR .

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