What is the time complexity T(n) of the following program? a) int n, d, i, j; cin >> n; for (d=1; d<=n; d++) for (i=1; i<=d; i++) for (j=1; j<=n; j += n/10) cout << d << " " << i << " " << j << endl; b) void main() { int n, s, t; cin >> n; for (s = 1; s <= n/4; s++) {t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } } c) void main() { int n, r, s, t; cin >> n; for (r = 2; r <= n; r = r * 2) for (s = 1; s <= n/4; s++) { t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } }
3 9327Coin Problem You are given 9 gold coins that look identical. One is counterfeit and weighs a bit greater than the others, but the difference is very small that only a balance scale can tell it from the real one. You have a balance scale that costs 25 USD per weighing. Give an algorithm that finds the counterfeit coin with as little weighting as possible. Of primary importance is that your algorithm is correct; of secondary importance is that your algorithm truly uses the minimum number of weightings possible. HINT: THE BEST ALGORITHM USES ONLY 2 WEIGHINGS!!!
1 15006Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?
7462Complexity 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; } }
2727Complexity T(n) Write a linear-time algorithm that sorts n distinct integers, each of which is between 1 and 500. Hint: Use a 500-element array. (Linear-time means your algorithm runs in time c*n + b, where c and b are any constants that do not depend on n. For example, your algorithm can run in time n, or time 2n + 1, or time 5n + 10, or time 100n + 6, but not time c*n*n = c*n?.)
1 6610Subsets Write an algorithm that prints out all the subsets of 3 elements of a set of n elements. The elements of the set are stored in a list that is the input to the algorithm. (Since it is a set, you may assume all elements in the list are distinct.)
1 13349Min-Max Write an algorithm that finds both the smallest and largest numbers in a list of n numbers and calculate its complexity T(n).
1 6426Min-Max Write an algorithm that finds both the smallest and largest numbers in a list of n numbers and with complexity T(n) is at most about (1.5)n comparisons.
10 44172Faster Computers Suppose you have a computer that requires 1 minute to solve problem instances of size 1000. What instance sizes can be run in 1 minute if you buy a new computer that runs 1000 times faster than the old one, assuming the following time complexities T(n) for our algorithm? (a) T(n) = O(n). (b) T(n) = O(n3). (c) T(n) = O(10n).
1 10899Algorithm 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 6244Post New Qatar University C++ Code Interview Questions
How can I explain p2p process in SAP?
What is your expected date of graduation if you are still in school? If you have already graduated, what was your graduation date?
How can we submit a form in selenium?
What is a loop in r?
Tell me what is the difference between the following two lines of code?$('#Mymodalprompt').modal({ keyboard: false });$.fn.modal.constructor.defaults.keyboard = false;?
Can a varchar be a primary key?
46.How you can create cross joined output using join component ? 47.What is the default layout of watcher files ? How to use in abinitio graph? 48.Why you get 'too many open files' error ? How to use in abinitio graph? 49.What is the significance of vnode folder under AB_WORK_DIR ? How to use in abinitio graph? 50, What is the significance AB_AIR_BRANCH? How to use in abinitio graph? 51. How can you select only unique records from a set of records ? How to use in abinitio graph? 52. How next_in_sequence work in parallel layout ? How to use in abinitio graph? 53. Why you want to set a modest number in limit ? How to use in abinitio graph? 54. How you can encrypt a password and use it in dbc file? How to use in abinitio graph? 55. Which function you should be using if you do not want to process non printable char from a feed file ? How to use in abinitio graph? 56. How you can run a component for certain conditions ? How to use in abinitio graph? 56. What is catalog and when you should use it ? How to use in abinitio graph? 57. How you can use reformat as a router ? How to use in abinitio graph? 58. How many process gets created for a n-way parallel component ? How to use in abinitio graph? 59. Why delimited DMLs take more time to process than fixed length DMLs? How to use in abinitio graph? 60. How can you select only first and last record from a file without using next_in_sequence? How to use in abinitio graph? 61.Why you should always keep largest input as driving input for Join ? How to use in abinitio graph? 62. What a catalog file contains ? How to use in abinitio graph? 63. What Is private project and public project ? How to use in abinitio graph? 64. Why you should not use checkpoint after replicate ? How
please can any one tell me clearly about pid tuning i am confusing about this .how to tune pid easly?
What does reference means in actionscript?
What is sql partition?
How to import data to sap?
What is string in java? String is a data type?
Can we modify the attribute's value of the html tag dynamically?
What is the f1 score? How would you use it?
What is the difference between BPA AND Contract What are documents and test cases u followed