Design and Analysis of Algorithm, Past Papers, UOS Main Campus

Analysis of Algorithms BSCS 5th Mid Past Paper – UOS Main Campus

ProgramBSCS
Semester5th
ExamMid Term
CampusUOS Main
AnswersSolved ✓

University of Sargodha main campus (Department of Computer Science & Information Technology) Analysis of Algorithms mid-term exam for BSCS 5th (20 marks, 60 minutes). Retyped from the original paper, with solved answers below.

Solved answers

Q1 – B-tree insertion, t = 2 (04)

With t = 2 a node holds 1 to 3 keys. Using the CLRS method (split a full node on the way down):

  • 5, 9, 3 → [3 5 9] (root is now full).
  • 7 → root full, split: [5] with children [3] and [7 9].
  • 1 → [1 3]; 2 → [1 2 3]; 8 → [7 8 9].
  • 6 → child [7 8 9] is full, split: root [5 8], children [1 2 3] [6 7] [9].
  • 0 → child [1 2 3] is full, split: root [2 5 8], children [0 1] [3] [6 7] [9].
  • 4 → root [2 5 8] is full, split: new root [5].

Final B-tree: root [5]; left child [2] with leaves [0 1] and [3 4]; right child [8] with leaves [6 7] and [9].

Q2 – 10× faster algorithm or 10× faster machine? (04)

A faster algorithm is usually better. A 10× faster machine only multiplies speed by a constant, while a better algorithm improves the growth rate. Example: for an O(2ⁿ) algorithm, a 10× faster machine lets n grow by only about 3 (log₂10), but an O(n²) algorithm on the old machine can handle far larger inputs. For large inputs the order of growth matters more than constant factors.

Q3 – Linear probing, m = 9 (04)

h(k) = k mod 9: 37 → 1; 3 → 3; 5 → 5; 42 → 6; 17 → 8; 11 → 2; 20 → 2 (taken by 11), 3 (taken), 4.

Slot012345678
Key–3711320542–17

Q4 – Smallest n with 110n³ < 5ⁿ (04)

n = 6: 110·216 = 23,760 > 5⁶ = 15,625. n = 7: 110·343 = 37,730 < 5⁷ = 78,125. So the smallest n is 7.

Q5 – Adjacency matrix (04)

Edges: 1–2, 1–3, 2–3, 3–4 (undirected).

1234
10110
21010
31101
40010
Save this paper for offline studyDownload the question paper, or save the paper together with all solved answers as a PDF.
↓ Download Paper (JPG)

About Saif R

An educator and technology enthusiast passionate about empowering students through quality education and digital learning. Dedicated to making academic resources and opportunities accessible to everyone.