Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 big-oh notation
Index -> Programming, C++ -> C++ Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rickdragon




PostPosted: Tue Jan 13, 2004 9:18 pm   Post subject: big-oh notation

/*
Give using "big-oh" notation, the worst case running time
of following procedure as a function of n

int recursive(int n)
{
if(n<=1)
return 1;
else
return(recursive(n-1)+recursive(n-1));
}
*/


#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
puts("Enter n :");
scanf("%d",&n);
printf("A = %d",recursive(n));
getch();
}
int recursive(int n)
{
if(n<=1)
return 1;
else
return(recursive(n-1)+recursive(n-1));
}
Sponsor
Sponsor
Sponsor
sponsor
McKenzie




PostPosted: Wed Jan 14, 2004 11:31 am   Post subject: (No subject)

Are you asking for someone to give the big O notation (i.e. as sort of a helpfull little quiz?), or are you claiming that your program gives big O notation? If it is the first, cool, I won't answer it, and spoil everyone's fun but if it is the second your program does not quite solve the problem
Display posts from previous:   
   Index -> Programming, C++ -> C++ Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: