Computer Science EngineeringVery hardISRO SC (CS)
Consider the following C fragment. int c=0; for(int i=1;i<=40;i*=2) for(int j=1;j<=i;j++) c++; What is c at the end?
- A. 63
- B. 57
- C. 240
- D. 126
Correct answer: A. 63
Simulating the loops gives 63. The distractors come from the usual slips: off-by-one at a boundary (< vs <=), dropping a loop level, or using a cruder asymptotic estimate instead of the exact count.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- The length of a longest common subsequence of DAAAADDCBB and CBCCDCBBA is:
- Using the Master theorem (extended form), the solution of T(n) = 4T(n/2) + n log^2 n is:
- The keys [40, 18, 25, 51, 17, 19] are inserted in this order into an initially empty AVL tree. The height of the final tree, counted in…
- 0/1 knapsack: item weights [4, 3, 3, 8, 7], values [18, 11, 18, 8, 4], capacity 15. The maximum total value is:
- The number of distinct spanning trees of the complete bipartite graph K2,4 is:
- The number of distinct permutations of 1..6 that can be produced as output by pushing 1,2,...,6 in order onto a stack and popping at any…