Click here to Skip to main content
16,016,087 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CButton and Bitmap Interface :: MFC Pin
valikac16-Feb-03 14:14
valikac16-Feb-03 14:14 
GeneralRe: CButton and Bitmap Interface :: MFC Pin
valikac16-Feb-03 14:42
valikac16-Feb-03 14:42 
QuestionAdding clipping rect to DC? Pin
Moak16-Feb-03 11:12
Moak16-Feb-03 11:12 
AnswerRe: Adding clipping rect to DC? Pin
Paul M Watt17-Feb-03 8:37
mentorPaul M Watt17-Feb-03 8:37 
GeneralRe: Adding clipping rect to DC? Pin
Moak17-Feb-03 21:22
Moak17-Feb-03 21:22 
GeneralGetting strings from a Combo Box Pin
DuFF16-Feb-03 10:18
DuFF16-Feb-03 10:18 
GeneralRe: Getting strings from a Combo Box Pin
DuFF17-Feb-03 15:23
DuFF17-Feb-03 15:23 
GeneralImproving time complexity of O(nlgn) recursive program Pin
GabyGirl16-Feb-03 9:45
GabyGirl16-Feb-03 9:45 
I have a program that calculates an exponent recursively. It's time complextity is O(n lg n). I would like to know whether anybody knows how I can improve my program to make it into a O(lg n) program. Please help!!!

here is my code:

#include <iostream.h><br />
#include <math.h><br />
#include <ctime><br />
<br />
//Function Prototypes<br />
void PersonalDisplay(void);<br />
int powerNOTRECURSIVE(int x, unsigned n);<br />
int powerRECURSIVE(int n, int k);<br />
<br />
void main(void){<br />
<br />
<br />
long ans=0;<br />
long base=0;<br />
long exponent=0;<br />
<br />
clock_t startclock = 0;<br />
clock_t endclock = 0;<br />
<br />
<br />
<br />
cout<<endl;<br />
<br />
cout<<"Enter the base: "<<endl;<br />
cin>>base; <br />
cout<<endl;<br />
cout<<"Enter the exponent: "<<endl;<br />
cin>>exponent; <br />
cout<<endl;<br />
<br />
  <br />
cout<<"Calling the RECURSIVE function...."<<endl;<br />
startclock = clock(); //Start sys clock<br />
ans=powerRECURSIVE(base,exponent);<br />
endclock = clock(); //End sys clock<br />
cout << "NonRecursive Time: " << (endclock-startclock) << endl;<br />
cout<<ans;<br />
}<br />
<br />
//Recursive Approach<br />
int powerRECURSIVE(int n, int k){<br />
	if(k==0) return 1;<br />
	int m=k>>1;<br />
	int z=powerRECURSIVE(n,m)*powerRECURSIVE(n,m);<br />
	if(k && 1)return z*n;<br />
	return z;<br />
}


GabyGirl
GeneralRe: Improving time complexity of O(nlgn) recursive program Pin
Joaquín M López Muñoz16-Feb-03 10:17
Joaquín M López Muñoz16-Feb-03 10:17 
GeneralCode Correction Pin
GabyGirl16-Feb-03 16:10
GabyGirl16-Feb-03 16:10 
GeneralRe: Improving time complexity of O(nlgn) recursive program Pin
JohnMcL17-Feb-03 2:06
JohnMcL17-Feb-03 2:06 
GeneralRegistry and C++/MFC Pin
LiquidKnight16-Feb-03 9:39
LiquidKnight16-Feb-03 9:39 
GeneralCD Serial Number Pin
Sassan Komeili Zadeh16-Feb-03 9:16
Sassan Komeili Zadeh16-Feb-03 9:16 
GeneralRe: CD Serial Number Pin
Jon Hulatt17-Feb-03 1:51
Jon Hulatt17-Feb-03 1:51 
GeneralMake Callback function as member function ! Pin
Hadi Rezaee16-Feb-03 6:56
Hadi Rezaee16-Feb-03 6:56 
GeneralRe: Make Callback function as member function ! Pin
Mohammed Saleem16-Feb-03 7:14
Mohammed Saleem16-Feb-03 7:14 
GeneralRe: Make Callback function as member function ! Pin
João Paulo Figueira16-Feb-03 7:37
professionalJoão Paulo Figueira16-Feb-03 7:37 
GeneralRe: Make Callback function as member function ! Pin
dlhson216-Feb-03 7:50
dlhson216-Feb-03 7:50 
GeneralRe: Make Callback function as member function ! Pin
João Paulo Figueira16-Feb-03 8:27
professionalJoão Paulo Figueira16-Feb-03 8:27 
GeneralRe: Make Callback function as member function ! Pin
Anonymous16-Feb-03 8:46
Anonymous16-Feb-03 8:46 
GeneralRe: Make Callback function as member function ! Pin
dlhson216-Feb-03 7:43
dlhson216-Feb-03 7:43 
QuestionHow do I get the frame? Pin
ROK_RShadow16-Feb-03 6:46
ROK_RShadow16-Feb-03 6:46 
AnswerRe: How do I get the frame? Pin
valikac16-Feb-03 7:55
valikac16-Feb-03 7:55 
GeneralRe: How do I get the frame? Pin
ROK_RShadow16-Feb-03 8:01
ROK_RShadow16-Feb-03 8:01 
GeneralRe: How do I get the frame? Pin
valikac16-Feb-03 8:34
valikac16-Feb-03 8:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.