Questions

3 Marks Each

🎯

Test yourself on this topic

4 questions · timed · auto-graded

Question 13 Marks
Write a program using recursion function to accept the list from the user and print sum of all the elements in the list.
View full question & answer
Question 23 Marks
Write different Time Complexity and Space Complexity of Bubble Sort, Selection Sort and Insertion Sort.
View full question & answer
Question 33 Marks
Understand the code, answer the following questions:

(a) What is the run-time efficiency of the following code segment?
(b) Write the output.
(c) What will be the runtime efficiency if $n=2$?
Answer
(a) There are three nested loops, each loop executed $3$ times (as $n=3$). So, run-time efficiency is $3X3X3 = 27$ or $nXnXn = n^3$.(b) Output is:
1 1 1
1 1 2
1 1 3
1 2 1
1 2 2
1 2 3
1 3 1
1 3 2
1 3 3
2 1 1
2 1 2
2 1 3
2 2 1
2 2 2
2 2 3
2 3 1
2 3 2
2 3 3
3 1 1
3 1 2
3 1 3
3 2 1
3 2 2
3 2 3
3 3 1
3 3 2
3 3 3
(c) If $n=2$ then, run-time efficiency is $2X2X2 = 8$.
View full question & answer
Question 43 Marks
Write the processing time of the below program code:

Write the programming code differently, calculate its time complexity.

Answer

Calculate the processing time:


Total: 7n/2+1 operations => 7n/2+1 units of processing time

Therefore, the time complexity is of the order O(n).

View full question & answer
3 Marks Each - Computer Science STD 12 Commerce Questions - Vidyadip