Blog
Artificial Intelligence BSCS 6th Mid Past Paper – UOS Main Campus
University of Sargodha main campus Artificial Intelligence mid-term exam for BSCS 6th (30 marks, 90 minutes). Retyped from the original paper (the graph has been redrawn), with solved answers below.
The weight of the C–E edge was not visible in the copy; the answers below do not depend on it except where noted (we assume it is at least 2).
Solved answers
Neighbours in alphabetical order: A: B, C, D, E · B: A, C, D, E · C: A, B, D, E · D: A, B, C, E · E: A, B, C, D. Edge costs: A–B 4, A–C 3, A–D 1, A–E 5, B–C 1, B–D 2, B–E 3, C–D 5, D–E 4.
1. State space graph for TSP (3)
Each state is a partial tour starting at A. Root: A → children AB, AC, AD, AE → each child expands to the unvisited cities (e.g. AB → ABC, ABD, ABE) … until all 5 cities are visited and the tour returns to A. There are 4! = 24 complete tours (12 distinct cycles).
2. Breadth-first search (4)
Queue: [A] → expand A, add B, C, D, E → expand B, C, D → E reached. Order of expansion: A, B, C, D, E. Path: A → E (depth 1).
3. Depth-first search (4)
A → B (first child) → C (first unvisited child of B) → D (first unvisited child of C) → E. Order: A, B, C, D, E. Path: A → B → C → D → E.
4. Depth-limited search, limit 2 (4)
A (depth 0) → B (1) → C (2, cut off), D (2, cut off), E (2) = goal. Path: A → B → E.
5. Iterative deepening search (4)
Limit 0: A (not goal). Limit 1: A, B, C, D, E → goal found at depth 1. Path: A → E.
6. Uniform cost search (4)
| Step | Expand | Frontier (path: cost) |
|---|---|---|
| 1 | A (0) | AD 1, AC 3, AB 4, AE 5 |
| 2 | D (1) | ADB 3, AC 3, AE 5 (ADE 5 not better), ADC 6 dropped |
| 3 | B (3, via D) | AC 3, AE 5 (ADBE 6 not better) |
| 4 | C (3) | AE 5 |
| 5 | E (5) = goal |
Goal E with cost 5, path A → E (A → D → E has the same cost 5).
7. Genetic algorithm crossover (3)
Fitness = tour length (lower is better). ABCDE = 4 + 1 + 5 + 4 + 5 = 19; EDCBA is the same tour reversed = 19; CDEAB is the same cycle started at C = 19. So all candidates have equal fitness 19 — any one can be taken as most fit and least fit. Single-point crossover between ABCDE and CDEAB (after position 2) with order repair gives AB|CDE and CD|EAB, i.e. the same cycle again. The next generation is 2 copies of each → all still cost 19; the population has no diversity, so crossover alone cannot improve it (mutation is needed).
8. Hill climbing (4)
Start ABCDE (cost 19). Neighbour by replacing two edges (2-opt, reverse B–C): ACBDE = 3 + 1 + 2 + 4 + 5 = 15 (better, move). Next, reverse D–E: ACBED = 3 + 1 + 3 + 4 + 1 = 12 (better, move). No neighbour of ACBED is cheaper among tours not using C–E, so hill climbing stops at A → C → B → E → D → A, cost 12 (this is also the best tour that avoids the unknown C–E edge).
