hey some one help me out in calculation O(n)

int koodle (int n)
{
int  j,k:int x;
if(n%2==0)
for(j=0;j<n;j++)
x+=rand()%2;
else
for(k=0;k<n;k++)
x+=rand()%2;
return x;
}


I need to obtain the time complexity of the above matrix transpose algorithm using program step count method.

Thanks for any help I can get on this.

## Recommended Answers

Hi there santhi1986 and welcome to Daniweb :)

We have a few rules here at Daniweb that you might want to read. Probably the most important one is that we can't do your homework for you, we need to see some effort before we try to guide you. What …

hey some one help me out in calculation O(n)

int koodle (int n)
{
int  j,k:int x;
if(n%2==0)
for(j=0;j<n;j++)
x+=rand()%2;
else
for(k=0;k<n;k++)
x+=rand()%2;
return x;
}


I need to obtain the time complexity of the above matrix transpose algorithm using program step count …

## All 8 Replies

Hi there santhi1986 and welcome to Daniweb :)

We have a few rules here at Daniweb that you might want to read. Probably the most important one is that we can't do your homework for you, we need to see some effort before we try to guide you. What do you think is the answer to your problem?

An unwritten rule in this forum is that we don't revive old threads to ask our questions. We prefer it if you start your own thread to ask your question even if it is related.

Anyway let us know what you've done to solve the problem and we will try to help you out :)

Cheers
darkagn

can you tell me the time complexity for
s=0;i=1;
while (s<n)
{s+=i;
i+=2;
}

i think the answer is O(square root of n)

commented: May be. +0

hai!!!!!!i need to calculate the time complexity ofthe following using logorithmic method
s=0;
for(i=1;i<=n;++i)
s+=i

good..going the homework assisgnment..from sac state

hi friends there
im satish from hyderabad
i ve some doubts can u please reply to my questions

the solution to the reccurance relation interms of big O notation
T(n)=T(n+1)+1
given that T(1)=1

hey some one help me out in calculation O(n)

int koodle (int n)
{
int  j,k:int x;
if(n%2==0)
for(j=0;j<n;j++)
x+=rand()%2;
else
for(k=0;k<n;k++)
x+=rand()%2;
return x;
}


I need to obtain the time complexity of the above matrix transpose algorithm using program step count method.

Thanks for any help I can get on this.

hi there,

here's a couple links based on obtaining Time Complexity algorithm
http://www.cs.uiowa.edu/~jier/cs3/2003-11-11_discussion.pdf
http://www.cs.wisc.edu/~hasti/cs367-common/notes/COMPLEXITY.html

hope this will solve your query.
Thank you
Jitesh
.Net Consulting

Satish how do I solve this?? by recursion method???

ohk... iam trying....

T(n)=T(n+1)+1
now, put n+1 in the place of n
so
T(n)=T(n+2)+1+1
T(n)=T(n+3)+1+1+1
..................
T(n)=T(n+k)+k
here T(1)=1;
so
n+k=1
or,k=1-n
so,T(n)=T(n+1-n)+1-n
so,T(n)=T(1)+1-n
so'T(n)=1+1-n=2-n;answer...

commented: Old thread, do no wake up the zombies ;) -3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.