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
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,
Write a program using one dimensional array that searches a number and display the number of times it occurs on the list of 12 input values. Sample input/output dialogue: Enter 12 values: 13 15 20 13 30 35 40 16 18 20 18 20 Enter number to search: 20 Occurences: 3
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.
what is the use of using for loop as "for(;;)"?
. Remove all the blank spaces between character.Matrix is of 10* 10. eg: INPUT ------------------------------------ | N | A | | V | |T ------------------------------------- | |G | U | |P | -------------------------------------- |T | | | A | | ------------------------------------ OUTPUT: ------------------------------------ | N | A | V | T | | ------------------------------------- |G |U | P | | | -------------------------------------- |T | A | | | | ------------------------------------
Deriving time complexity of Binary tree and AVL tree, step by step.
Write A C++ Program To Input A Number Between 20 To 99 And Display Its Numbername?
Write a program to enter 10 number of integer entries into an array n and then odds up all the odd entries. the program then displays the result. plssss answer assss fast asss u can...
Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.
0 Answers Facebook, Webyog, Wipro,
a program using one dimensional array that searches a number if it is found on the list of given input numbers given by the user and locate its exact location in the list.. ""EXAMPLE"" enter how many numbers to be inputted: 5 12 14 11 09 30 what number to search: 11 11 IS FOUND IN LOCATION 3 PLZZZ.. ELP ME...
How to swap two ASCII numbers?
find level of following tree (state, parent) " J,D I,D H,C E,B F,B G,C B,A D,A C,A A,& K,E L,E L,F M,F N,G O,H P,I P,H Q,I R,J S,K U,P T,L