Artificial Intelligence, Past Papers, UOS Main Campus

Artificial Intelligence Past Paper 2018 – BSCS 6th Term UOS (CS-3811)

ProgramBSCS
Term6th
Year2018
Course codeCS-3811
AnswersSolved ✓

University of Sargodha BS Computer Science 6th term examination 2018, Artificial Intelligence (CS-3811) paper (80 marks, 2:30 hours). The paper is retyped by Shining Study from a student’s copy (marks, names and roll numbers removed); all answers are written by Shining Study for revision. The top line of the header is cut in the copy we have, so the year (2018) is taken from the same set of papers it came with. Solved answers for all 16 short questions and the subjective questions: predicate logic, AI problem components, forward chaining, Bayes’ theorem and uninformed search, a worked Naive Bayes example (answer: fever = yes), an XNOR neural network and conditional independence.

Solved answers

Q1 – Short answers (16 × 2)

i. Biological neuron and its parts. A neuron has dendrites (receive signals from other neurons), the cell body / soma with the nucleus (adds up the incoming signals), the axon (carries the output signal away) and synapses / axon terminals (junctions that pass the signal to the next neuron). Sketch: branches (dendrites) → round soma → long axon → terminal branches.

ii. Probabilistic reasoning. Reasoning with degrees of belief (probabilities) instead of true/false facts, used when knowledge is uncertain or incomplete. Examples: P(rain | cloudy) = 0.7 for a weather agent; a medical system computing P(flu | fever, cough); spam filters computing P(spam | words).

iii. BFS vs DFS. BFS expands the shallowest node first using a FIFO queue; it is complete and optimal for equal step costs but needs O(bd) memory. DFS expands the deepest node first using a LIFO stack; it needs little memory O(bm) but is not optimal and may loop in infinite/cyclic spaces.

iv. Heuristic h in A*. h(n) is an estimate of the cost from node n to the goal, usually from a relaxed problem, e.g. straight-line distance in route finding, or the number of misplaced tiles / Manhattan distance in the 8-puzzle. A* then uses f(n) = g(n) + h(n). For optimal results h must be admissible (never overestimates).

v. Functionalities of an agent function. The agent function maps every percept sequence to an action: f : P* → A. It takes percepts from sensors, keeps/updates internal state (in model-based agents), chooses an action according to rules, goals or utility, and sends it to the actuators.

vi. Heuristic vs algorithm. An algorithm is a precise step-by-step procedure that always gives a correct result in finite time. A heuristic is a rule of thumb that guides search toward a good solution quickly but does not guarantee the best (or any) solution.

vii. Artificial vs biological neuron. A biological neuron is a living cell with chemical/electrical signals, about 1011 of them work massively in parallel and learn by changing synapses. An artificial neuron is a mathematical unit: weighted sum of inputs + bias passed through an activation function; networks are much smaller and learn by adjusting weights (e.g. backpropagation).

viii. Limitations of A*. Memory: it keeps all generated nodes, so space grows exponentially; time can still be exponential if h is weak; optimality depends on an admissible (and for graph search, consistent) heuristic; a good heuristic is hard to design. Variants like IDA* and SMA* reduce memory.

ix. Hypothetical Syllogism and Modus Tollens. Hypothetical syllogism: from P → Q and Q → R infer P → R (generalised: P1→P2, P2→P3, …, Pn−1→Pn ⊢ P1→Pn). Modus tollens: from P → Q and ¬Q infer ¬P.

x. Knowledge representation. The way facts about the world are stored so that a program can reason with them. Examples: propositional/predicate logic (∀x Man(x) → Mortal(x)), semantic networks, frames, production rules (IF fever AND rash THEN measles), and Bayesian networks.

xi. Artificial neuron for NOR. Inputs x1, x2 with weights w1 = w2 = −1, bias b = +0.5, step activation (output 1 if sum ≥ 0). Sum = 0.5 − x1 − x2: (0,0) → 0.5 → 1; (0,1), (1,0) → −0.5 → 0; (1,1) → −1.5 → 0. This is NOR.

xii. Significance of synapses. Synapses are the connections where one neuron passes its signal to another. Their strength decides how much one neuron affects the next, and changes in synaptic strength are how the brain learns and stores memory. In artificial networks they correspond to the weights.

xiii. Bayes’ theorem. P(A | B) = P(B | A) · P(A) / P(B), where P(A) is the prior, P(B | A) the likelihood, P(B) the evidence and P(A | B) the posterior.

xiv. Constraint satisfaction problem. A problem defined by variables, a domain of values for each, and constraints that the values must satisfy; a solution assigns values to all variables without breaking any constraint. Example: map colouring – colour the regions of a map with {red, green, blue} so that no two neighbours have the same colour (also Sudoku, 8-queens, timetabling).

xv. Forward vs backward chaining. Forward chaining is data-driven: start from known facts, fire rules whose conditions are true and add new facts until the goal appears. Backward chaining is goal-driven: start from the goal and work back through rules to find facts that support it (used in Prolog and diagnosis systems).

xvi. Improving search effectiveness. Use good (admissible, informed) heuristics; avoid repeated states with a closed list; prune with constraints (forward checking, alpha-beta in games); choose a good search strategy (A*, iterative deepening, bidirectional search); good problem formulation and ordering of operators.

Q2 (a) – Sentences in predicate logic

  1. ∀x Food(x) → Likes(John, x)
  2. Food(Apples)
  3. Food(Chicken)
  4. ∀x ∀y (Eats(y, x) ∧ ¬KilledBy(y, x)) → Food(x)
  5. Eats(Bill, Peanuts) ∧ Alive(Bill)
  6. ∀x Eats(Bill, x) → Eats(Sue, x)

(Often added to finish the proof: ∀x ∀y Alive(x) → ¬KilledBy(x, y). Then from v, Bill eats peanuts and is not killed by them, so by iv Food(Peanuts), and by i Likes(John, Peanuts).)

Q2 (b) – Components of an AI problem

  • Initial state – where the agent starts.
  • Actions / operators – what the agent can do in each state.
  • Transition model – the result of each action.
  • Goal test – checks whether a state is a goal.
  • Path cost – numeric cost of a sequence of actions.

Example – 8-puzzle: state = positions of 8 tiles and the blank; initial state = any given arrangement; actions = move blank Left, Right, Up, Down; transition = swap blank with neighbouring tile; goal = tiles in order 1–8; path cost = 1 per move. Example – route finding: states are cities, actions are roads, cost is distance, goal is the destination.

Q3 – Forward chaining

Forward chaining is a data-driven inference method. It starts with the known facts in working memory and repeatedly applies rules (IF conditions THEN conclusion) whose conditions are satisfied, adding the conclusions as new facts, until the goal is derived or no rule can fire.

Algorithm:

  1. Put all known facts in the agenda / knowledge base.
  2. Find every rule whose premises are all true (matched by the facts).
  3. Fire such a rule: add its conclusion as a new fact (if not already known).
  4. If the new fact is the goal, stop with success.
  5. Repeat steps 2–4 until no new fact can be added; then stop (goal not provable).

Example: Rules: R1: A ∧ B → C; R2: C → D; R3: D ∧ E → F. Facts: A, B, E. Goal: F.
Step 1: R1 fires (A, B true) → add C. Step 2: R2 fires → add D. Step 3: R3 fires (D, E true) → add F. Goal reached.

Q4 (a) – Uncertain knowledge and Bayes’ theorem

  • Uncertain knowledge: knowledge where facts or rules are not certainly true – due to incomplete information, noisy sensors or rules with exceptions (e.g. “toothache usually means cavity”).
  • Prior (unconditional) probability P(A): degree of belief in A before any evidence, e.g. P(Cavity) = 0.2.
  • Conditional (posterior) probability P(A | B): probability of A given that B is known, e.g. P(Cavity | Toothache) = 0.6; P(A | B) = P(A ∧ B) / P(B).
  • Bayes’ theorem: P(A | B) = P(B | A) P(A) / P(B).

Use in decision making: it lets an agent update beliefs from causal knowledge (P(effect | cause)) to diagnostic knowledge (P(cause | effect)) when new evidence arrives. Example: meningitis causes stiff neck 50% of the time, P(M) = 1/50000, P(S) = 1/20, so P(M | S) = 0.5 × (1/50000) / (1/20) = 0.0002. The agent then picks the action with the highest expected utility using these probabilities.

Q4 (b) – Uninformed (blind) search strategies

StrategyHow it worksComplete / OptimalTime / Space
Breadth-firstExpand shallowest node (FIFO queue)Yes / Yes (equal costs)O(bd) / O(bd)
Uniform-costExpand lowest path cost g(n) (priority queue)Yes / YesO(b1+C*/ε)
Depth-firstExpand deepest node (LIFO stack)No / NoO(bm) / O(bm)
Depth-limitedDFS with depth limit lNo / NoO(bl) / O(bl)
Iterative deepeningDFS with limit 0, 1, 2, … until goalYes / Yes (equal costs)O(bd) / O(bd)
BidirectionalSearch forward from start and backward from goal until they meetYes / Yes (with BFS)O(bd/2)

Here b = branching factor, d = depth of shallowest goal, m = maximum depth, C* = cost of optimal solution.

Q5 – Naive Bayes prediction

From the table (10 rows): Fever = yes in 2 rows, Fever = no in 8 rows.

QuantityFever = yesFever = no
Prior P(Fever)2/10 = 0.28/10 = 0.8
P(D = Allergy | Fever)1/25/8
P(Sneeze = yes | Fever)2/2 = 15/8
P(Cough = yes | Fever)1/20/8 = 0
Product0.2 × 0.5 × 1 × 0.5 = 0.050.8 × 0.625 × 0.625 × 0 = 0

Normalising: P(Fever = yes | Allergy, Sneeze = yes, Cough = yes) = 0.05 / (0.05 + 0) = 1. Prediction: Fever = yes.

Note: the 0 comes from no “cough = yes” among the fever = no rows. With Laplace smoothing (add 1) the scores are about 0.0375 (yes) and 0.0245 (no), so the answer is still yes (≈ 60%).

Q6 (a) – Artificial neuron for XNOR

XNOR is not linearly separable, so one neuron cannot do it; a small two-layer network is used (step activation, output 1 if sum ≥ 0):

  • Hidden neuron h1 (AND): weights 1, 1, bias −1.5 → h1 = 1 only for (1,1).
  • Hidden neuron h2 (NOR): weights −1, −1, bias +0.5 → h2 = 1 only for (0,0).
  • Output neuron (OR of h1, h2): weights 1, 1, bias −0.5.
x1x2h1h2XNOR
00011
01000
10000
11101

Q6 (b) – Representing knowledge in an uncertain domain

  • Probability theory / full joint distribution – degrees of belief for every combination of variables (too large in practice).
  • Bayesian (belief) networks – a directed acyclic graph where nodes are random variables and arrows show direct influence; each node has a conditional probability table P(X | Parents). The joint distribution is the product of these tables, which is compact and supports inference (e.g. Burglary → Alarm ← Earthquake; Alarm → JohnCalls, MaryCalls).
  • Other approaches – certainty factors (MYCIN), Dempster–Shafer theory, fuzzy logic for vague terms like “tall” or “hot”.

Q7 – Independence vs conditional independence

IndependenceConditional independence
A and B are independent if P(A | B) = P(A), i.e. P(A ∧ B) = P(A) P(B).A and B are conditionally independent given C if P(A | B, C) = P(A | C), i.e. P(A ∧ B | C) = P(A | C) P(B | C).
Knowing B tells nothing about A at all.Once C is known, B adds nothing more about A (they may still be related when C is unknown).
Example: weather and a toothache.Example: Toothache and Catch are both caused by Cavity; given Cavity they are independent.
Rare in practice.Very common; it is the basis of Bayesian networks and Naive Bayes, which reduces the number of probabilities from O(2n) to O(n).
Save this paper for offline studyDownload the question paper, or save the paper together with all solved answers as a PDF.
↓ Download Paper (JPG)
Have another year of Artificial Intelligence?

Upload a photo in 10 seconds — no form to fill. We clean it, solve it and credit you.

Missing years for this subject
202620242023

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.