[Type B] Chapter– 7 Class 12 CS – Sumita Arora Assignment | Q/A

Here is class 12 computer science Unit 7 [Type B] solutions for Sumita Arora back exercise assignment. Below includes both textual and video solutions wherever required. View all the answers in assignment for chapter 7 and for all chapters here.

Watch all tutorials for chapter 7.

Q1: Calculate the run-time efficiency of the following program segment:
Chapter 7 Type-B Sumita Arora
Question 1

Solution:

O(n)

Due to the while loop having upper bound input i.e. n
Q2: Calculate the run-time efficiency of the following program segment:
Chapter 7 Type-B Sumita Arora
Question 2

Solution:

O(n^3)

Due to the three nested while loop each having n and product of three loop i.e. n^3.
Q3: If the function doIt() has an efficiency factor of 5n, calculate the run-time efficiency of the following program segment.
Chapter 7 Type-B Sumita Arora
Question 3

Solution:

O(5n^2)

Due to the nesting of the doIt() and having 5n in product with n for the while loop.
Q4: If the efficiency of the function doIt() can be expressed as O(n)=n^2, calculate the efficiency of the following program segment.
Chapter 7 Type-B Sumita Arora
Question 4

Solution:

O(n) = n^4

Due to the nested while loop having upper bound input i.e. n hence it gives n^2 in product with nested function doIt() having O(n) = n^2.
Q5: If the efficiency of the function doIt() can be expressed as O(n)=n^2, calculate the efficiency of the following program segment.
Chapter 7 Type-B Sumita Arora
Question 5

Solution:

O(n) = n^3

Due to the while loop having upper bound input i.e. n and the nested function doIt() having O(n) = n^2. Hence O(n) =n*n^2
Q6: Given a list A of appropriate size, what is the complexity of the following code in terms of n?
Chapter 7 Type-B Sumita Arora
Question 6

Solution:

O(n) = n

As the while loop will execute for the n times because i is initialized with n in the starting.
Q7: Given three lists A, B, C of appropriate sizes, what is the complexity of the following code in terms of n,m, and p?
Chapter 7 Type-B Sumita Arora
Question 7

Solution:

O(n) = n*p*m

The all three nested loop will be get product with upper bound to provide the complexity.
Q8: Given integer variable x and a list A of appropriate size, what is the complexity of the following code in terms of n?
Chapter 7 Type-B Sumita Arora
Question 8

Solution:

O(n) = logn

As of the mid positioning property similar to binary search.
Q9: Given a list A of appropriate size, what is the complexity of the following code in terms of n?
Chapter 7 Type-B Sumita Arora
Question 9

Solution:

O(n) = 2n

The two concatenate for loop of each upper bound n will be added to result the complexity.
O(n) = n+n
Q10: Given a list A of appropriate size, what is the complexity of the following code in terms of n?
Chapter 7 Type-B Sumita Arora

Solution:

O(n) = n^2
Q11: Given a list A of appropriate size, what is the complexity in terms of n?
Chapter 7 Type-B Sumita Arora
Question 11

Solution:

O(n) = n
 
The while loop will execute for the n times as if bound has at most limit is n.
Q12: Given integer variable x and a list A of appropriate size, what is the complexity of the following code in terms of n?
Chapter 7 Type-B Sumita Arora
Question 12

Solution:

O(n) = logn

As of the mid positioning property similar to binary search.
Q13: Given a list A of appropriate size, what is the complexity in terms of n?
Chapter 7 Type-B Sumita Arora
Question 13

Solution:

O(n) = 2n

The two concatenate for loop of each upper bound n will be added to result the complexity.
O(n) = n+n
Q14: What is the time complexity of the following algorithms?
(i) Insertion Sort
O(n^2)

(ii) Binary Search
O(logn)

(iii) Linear Search
O(n)

Q15: Based on the complexity analysis, which sorting algorithm is more efficient and why?
Binary sort will be a good option as of having O(logn) time complexity than the other mentioned options.

Clear Doubts with Computer Tutor
In case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community: students.computertutor.in

You cannot copy content of this page