0% found this document useful (0 votes)
26 views3 pages

Midterm Exams Pattern UE (FALL-2024)

Uploaded by

Nadeem Mehmood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

Midterm Exams Pattern UE (FALL-2024)

Uploaded by

Nadeem Mehmood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Punjab Colleges,

Lahore
MID-TERM EXAMINATION (FALL 2024)
BS PROGRAMS [UNIVERSITY OF EDUCATION]
Course Name (with Code): Design and Analysis of Algorithm
Course Instructor: Muhammad Nadeem Program & Term: BSCS 22 A & B
Time Allowed: 15 Min Maximum Marks: 12
TO BE FILLED IN BY THE STUDENT
Registration No:
Student Name:
University Roll No.: bsf

(OBJECTIVE)
Attempt all questions. (12×1=12)

1. Which of the following statements is true about Big O notation?


(a) It represents the best-case time complexity. (b) It represents the average-
case time complexity.
(c) It represents the upper bound of time complexity. (d It represents the lower bound
of time complexity.)
2. What is the time complexity of the following loop?
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
// some constant time operation
}
}
(a) O(n) (b) O(n log n) (c) O(n^2) (d) O(2^n)
3. Which of the following sorting algorithms has a space complexity of O(1)?
(a) Bubble sort (b) Selection sort (c) Insertion sort (d) All of the
these
4. Which of the following sorting algorithms is a non-comparison sort?
a) Bubble sort b) Selection sort c) Insertion sort d) Counting sort
5. Which of the following sorting algorithms is known for its efficiency in sorting large
datasets?
a) Bubble sort b) Selection sort c) Insertion sort d) Heap sort
6. Which of the following is true about the function f(n) = 2n^2 + 3n + 1?
a) f(n) = O(n) b) f(n) = O(n log n) c) f(n) = O(n^2) d) f(n) = O(2^n)
7. Which of the following functions has a time complexity of O(log n)?
a) f(n) = n^2 b) f(n) = n log n c) f(n) = log n d) f(n) = n!
8. Which algorithm has the lowest time complexity for sorting when the input is mostly
sorted?

(a) Bubble Sort (b) Insertion Sort (c) Quick Sort (d) Selection Sort

9. The auxiliary space required by Merge Sort is:


Page 1 of 3
(a) O(n) (b) O(log n) (c) O(1) (d) O(n²)
10. Which statement about Stable and Unstable sorting algorithms is true?
(a) Stable sorting algorithms change the relative order of equal elements
(b) Unstable sorting algorithms preserve the relative order of equal elements
(c) Stable sorting algorithms preserve the relative order of equal elements
(d) None of the above
11. In Insertion Sort, the number of comparisons in the best case is:
(a) O(n) (b) O(n log n) (c) O(1) (d) O(n²)
12. The average-case time complexity of Quick Sort is:
(a) O(n) (b) O(n²) (c) O(n log n) (d) O(log n)

Page 2 of 3
Punjab Colleges,
Lahore
MID-TERM
EXAMINATION (FALL 2024)
BS PROGRAMS [UNIVERSITY OF EDUCATION]
Course Name (with Code): Design and Analysis of Algorithm
Course Instructor: Muhammad Nadeem Program & Term: BSCS 22 A & B
Time Allowed: 75 Min Maximum Marks: 38
TO BE FILLED IN BY THE STUDENT
Registration No:
Student Name:
University Roll No.: bsf

(SUBJECTIVE)
SHORT QUESTIONS
Q.1. Attempt all questions. (5×3=15)

1. Define asymptotic notation and explain its importance in analyzing algorithms.


2. Compare and contrast time complexity and space complexity.
3. What is the time complexity of the following function: f(n) = 2n + 3?
4. Explain the difference between Big O and Big Ω notation.
5. Describe the importance of analyzing an algorithm.

LONG QUESTIONS
Q.2. Attempt all questions. (8×2 = 16 & 7×1 =7)

(a) Explain the concept of stable and unstable sorting algorithms. Provide examples of each
type.
(b) Explain the concept of Counting sort and provide a scenario where it is particularly useful.
(c) Explain the working of Quick Sort with the help of an example. Analyze its time
complexity in the best, worst, and average cases.

Page 3 of 3

You might also like