-2

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.

Edited by diafol: fixed formatting

7
Contributors
8
Replies
11
Views
9 Years
Discussion Span
Last Post by srabasti
1

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

1

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)

Votes + Comments
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

-1

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

0

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

Edited by mike_2000_17: Fixed formatting

-2

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

Votes + Comments
Old thread, do no wake up the zombies ;)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.