Complexity T(n)
What is the time complexity T(n) of the following portions
of code? For simplicity, you may assume that n is a power of
2. That is, n = 2k for some positive integer k.
a) ?
for (i = 1; i <= n; i++)
{
j = n; cout << i << ? ? j << ? ? << endl;
}
b) ?
for (i = 0; i <= n; i += 2)
{
j = n; cout << i << ? ? j << ? ? << endl;
}
c) ?
for (i = n; i >= 1; i = i/2)
{
j = n; cout << i << ? ? j << ? ? << endl;
}
d)
for (i = 1; i <= n; i++)
{ j = n;
while (j >= 0)
{ cout << i << ? ? j << ? ? << endl;
j = j - 2;
}
}
No Answer is Posted For this Question
Be the First to Post Answer
Code for Easily Using Hash Table?
Wrie a function which returns the most frequent number in a list of integers. Handle the case of more than one number which meets this criterion. public static int[] GetFrequency(int[] list)
Algorithm in O(2n) Presently we can solve in our hypothetical machine problem instances of size 100 in 1 minute using algorithm A, which is a O(2n). We would like to solve instances of size 200 in 1 minute using algorithm A on a new machine. What is the speed of the new machine should be?
2 Answers ABC, Qatar University,
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.
Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.
3 Answers TCS, Vimukti Technologies, Wipro,
Counting in Lojban, an artificial language developed over the last fourty years, is easier than in most languages The numbers from zero to nine are: 0 no 1 pa 2 re 3 ci 4 vo 5 mk 6 xa 7 ze 8 bi 9 so Larger numbers are created by gluing the digit togather. For Examle 123 is pareci Write a program that reads in a lojban string(representing a no less than or equal to 1,000,000) and output it in numbers.
Write code for the multiplication of COMPLEX numbers?
Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.
0 Answers Facebook, Webyog, Wipro,
1.program to add any two objects using operator overloading 2.program to add any two objects using constructors 3.program to add any two objects using binary operator 4.program to add any two objects using unary operator
what is virtual constroctor ? give an exam for it?-(parimal dhimmar)
void main() { int i,j=2; for(i=0;i<3;i++) if(j=i) cout<<"Lotus "; else cout<<"Rose "; } Its result is Rose Lotus Lotus.. How? Explain it?