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
can we declare an object of a class in another class?(assume both class as public classes)
write a program that calculate the volume of cylinder after user enters radius and height and show the algorithm used
1 Answers Jomo Kenyatta University,
A string of charaters were given. Find the highest occurance of a character and display that character. eg.: INPUT: AEGBCNAVNEETGUPTAEDAGPE OUTPUT: E
how to take time as input in the format (12:02:13) from user so that controls remains between these columns?
. Write a program using two-dimensional arrays that computes the sum of data in tows and the sum of data in columns of the 3x3 (three by three) array variable n[3][3].
Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.
0 Answers Facebook, Webyog, Wipro,
Given a table of the form: Product Sold on A 1/1/1980 B 1/1/1980 C 1/1/1980 A 1/1/1980 B 1/1/1980 C 2/1/1980 A 2/1/1980 There are 30 products and 10,000 records of such type. Also the month period during which sales happened is given to u. Write the program to display the result as: Product Month No. of copies A January 12 A February 15 A March 27 B January 54 B February 15 B March 10 C January 37
Write A C++ Program To Input A Number Between 20 To 99 And Display Its Numbername?
write a program that accepts a number and outputs its equivalent in words. take note that the maximum input is 3000
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.
5 Answers ADP, Amazon, HCL, IBM, Infosys, Satyam, TCS, Vimukti Technologies,
write a program that reverses the input number of n.Formulate an equation to come up with the answer.
write a function -oriented program that generates the Fibonacci, the current numbers of n(as input) and display them (series). In Fibonacci, the current third number is the sum of the previous number.