GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Placement Papers  >  Adobe  >  Placement Papers

 Print  |  
Question:  write an O(log2(N)) algorithm to find X^N



August 08, 2006 13:03:42 #6
 hari   Member Since: Visitor    Total Comments: N/A 

RE: write an O(log2(N)) algorithm to find X^N
 
int xpwrn(int x,int n){ if(n==1) return x ; else if(n>1) { if(n%2==0) { xpwrn(x,n/2)*xpwrn(x,n/2); } else { x*xpwrn(x,n/2)*xpwrn(x,n/2); } }}
     

 

Back To Question