⟩ Write an O(log2(N)) algorithm to find X^N?
int computeXn(int x, int n)
{
if(n == 2)
{
return x*x;
}
else if(n % 2 == 0)
{
int y = computeXn(x, n/2);
return y*y;
}
else if(n % 2 == 1)
{
int y = computeXn(x, n/2);
return y*y*x;
}
}
int computeXn(int x, int n)
{
if(n == 2)
{
return x*x;
}
else if(n % 2 == 0)
{
int y = computeXn(x, n/2);
return y*y;
}
else if(n % 2 == 1)
{
int y = computeXn(x, n/2);
return y*y*x;
}
}
What is the language from which Python has got its features or derived its features?
What are the disadvantages of the Python programming language?
What is the method does join() in python belong?
Explain about interpolation?
Explain about ruby code blocks?
Explain about ruby names?
Explain about Float, Dig and Max?
Explain about variables?
Explain about Class variable and global variable?
How does ruby deal with extremely large numbers?