CS502 - FINAL TERMA SUBJECTIVE SOLVED WITH REFERENCE.doc

Verified academic study resource for CS502 (Fundamentals of Algorithms) under the Computer Science at Virtual University of Pakistan. This DOC document (Final-Term Solved Past Paper & Examination Pack) covers Final-Term Exam Scope (Lectures 23 to 45) spanning approximately 320 pages across 4 curriculum modules, and is indexed for student examination review with instant in-browser preview and 100% free direct download.

Course
CS502 – Fundamentals of Algorithms
Faculty
Computer Science
Format
DOC
Type
Final-Term
Coverage
Final-Term Exam Scope (Lectures 23 to 45)
Tags
SUBJECTIVE, SOLVED, FINALTERM

Virtual University regulations strictly require achieving at least 20% marks in the Final-Term exam paper alone (typically 12+ marks out of 60) to pass CS502, regardless of midterm scores.

What this file covers — CS502 syllabus roadmap

  1. Object-Oriented Paradigms: Classes & Data Abstraction — Lectures 23 to 29 (Pages 281 to 360). 16% Final-Term Marks (Core OO Concepts)
  2. Inheritance Hierarchies & Dynamic Polymorphism — Lectures 30 to 36 (Pages 361 to 435). 20% Final-Term Marks (Virtual Functions & V-Tables)
  3. Templates, Standard Library & Persistent File I/O — Lectures 37 to 41 (Pages 436 to 510). 14% Final-Term Marks (Generic Code & Streams)
  4. Final-Term Examination Dossier & Capstone Synthesis — Lectures 42 to 45 (Pages 511 to 585). Final-Term Exam Synthesis (Lectures 23–45 Scope)

Frequently asked questions

Where can I download CS502 - FINAL TERMA SUBJECTIVE SOLVED WITH REFERENCE.doc for free?

You can preview and download "CS502 - FINAL TERMA SUBJECTIVE SOLVED WITH REFERENCE.doc" (CS502 DOC, ~320 pages) directly from the MIHORA VU Study Library (https://study.mihora.tech/doc/cs502-final-terma-subjective-solved-with-reference-doc) with 100% free high-speed downloads and zero registration requirements.

What syllabus chapters and lectures are covered in this CS502 file?

This document covers Final-Term Exam Scope (Lectures 23 to 45) across 4 distinct lecture units (Lectures 23 to 29, Lectures 30 to 36, Lectures 37 to 41, Lectures 42 to 45), featuring comprehensive definitions, solved objective questions, and examiner marking rubrics.

What is the passing criteria for CS502 under the VU 20% Two-Half Rule?

Under official Virtual University regulations, students must score at least 20% in the First Half (Quizzes, Assignments, GDBs, and Midterm combined) AND independently at least 20% in the Final-Term examination paper. Scoring under 20% in the final exam results in an automatic F grade regardless of earlier marks.

Are CS502 solved past papers and handouts verified for 2026 exams?

Yes. All CS502 materials on MIHORA VU—including Moaaz, Waqar Siddhu, and team archives—are reviewed against the current VU syllabus to help students prepare for 2026 Midterm, Final-Term, and online quiz examinations.

Inside this file

CS502 Fundamentals of Algorithms
Final TERM Subjective

Differentiate between back edge and forward edge Suppose you could prove that an NP-complete problem can not be solved in polynomial time. What would be the consequence?
Answer:

Back Edge
A back edge connects a vertex to an ancestor in a DFS-tree. Note that a self-loop is a back edge.
from descendent to ancestor
(u, v) where v is an ancestor of u in the tree.
DFS tree may only have a single back edge
A back edge is an arc whose head dominates its tail (tail -> head)
a back edge must be a part of at least one loop

Forward Edge

from ancestor to descendent
(u, v) where v is a proper descendent of u in the tree.
A forward edge is a non-tree edge that connects a vertex to a descendent in a DFS-tree.
Edge x-y is less than the capacity there is a forward edge x-y with a capacity equal to the
capacity and the flow

According to the question this means that the problem can be solved in Polynomial time using known NP problem can be solved using the given problem with modified input (an NP problem can be reduced to the given problem) then the problem is NP complete.
The main thing to take away from an NP-complete problem is that it cannot be solved in polynomial time in any known way. NP-Hard/NP-Complete is a way of showing that certain classes of problems are not solvable in realistic time.
Ref: Handouts Page No.128

Recursive explanation of dynamic programming.
Formulate the problem into smaller sub problems, find optimal solution to these sub problems in a bottom up fashion  then write an algorithm to find the solution of whole problem starting with base case and works it way up to final solution.

Answer:
Dynamic programming is essentially recursion without repetition. Developing a dynamic programming algorithm generally involves two separate steps:

Formulate problem recursively. Write down a formula for the whole problem as a simple
combination of answers to smaller sub problems.
Build solution to recurrence from bottom up. Write an algorithm that starts with base cases and works its way up to the final solution.
Ref: Handouts Page No.75

What is the cost of the following graph?

Cost =33

Answer:
A common problem is communications networks and circuit design is that of connecting together a set of nodes by a network of total minimum length. The length is the sum of lengths of connecting wires.

Consider, for example, laying cable in a city for cable t.v.

The computational problem is called the minimum spanning tree (MST) problem. Formally, we are given
a connected, undirected graph G = (V, E) Each edge (u, v) has numeric weight of cost. We define the cost of a spanning tree T to be the sum of the costs of edges in the spanning tree

w(T) = 	  Σ	w(u, v)
(u,v)2T

A minimum spanning tree is a tree of minimum weight The first is a spanning tree but is not a MST;
Ref: Handouts Page No.142


Let the adjacency list representation of an undirected graph is given below. Explain what general property of the list indicates that the graph has an isolated vertex.
   a  b  c  e
   b  a  d
   c  a  d  e  f
   d  b  c  f
   e  a  c  f
   f  c  d  e
   g

Answer:-
The main theorem which drives both algorithms is the following:
MST Lemma: Let G = (V, E) be a connected, undirected graph with real-valued weights on the edges.
Let A be a viable subset of E (i.e., a subset of some MST). Let (S, V − S) be any cut that respects A and let (u, v) be a light edge crossing the cut. Then the edge (u, v) is safe for A.

MST Proof: It would simplify the proof if we assume that all edge weights are distinct. Let T be any MST for G. If T contains (u, v) then we are done. This is shown in Figure 8.47 where the lightest edge (u, v) with cost 4 has been chosen.
Ref: Handouts Page No.144

Floyd Warshal algorithm with three recursive steps
    1. Wij = 0 if I = j
    2. Wij = w(i,j) if i != j and (i,j) belongs to E
    3. Wij = infinity  if i != j and (i,j) not belongs to E

Answer

The Floyd-Warshall algorithm: Step (i)

The Floyd-Warshall algorithm: Step (ii)
Recursively define the value of an optimal solution.
Boundary conditions: for k = 0, a path from vertex i to j with no intermediate vertex numbered higher than 0 has no intermediate vertices at all, hence d (0)= wij

Recursive formulation:



	is the solution for this APSP problem:

The Floyd-Warshall algorithm: Step (iii)
Compute the shortest-path weights bottom up
FLOYD-WARSHALL(W, n)

Ref: Handouts Page No.161

Give a detailed example for 2d maxima problem
Answer:-
The problem with the brute-force algorithm is that it uses no intelligence in pruning out decisions.

For example, once we know that a point pi is dominated by another point pj, we do not need to use pi for eliminating other points. This follows from the fact that dominance relation is transitive. If pj dominates pi and pi dominates ph then pj also dominates ph; pi is not needed.
Ref: Handouts Page No.17

How the generic greedy algorithm operates in minimum spanning tree?
Answer:-
A generic greedy algorithm operates by repeatedly adding any safe edge to the current spanning tree. When is an edge safe? Consider the theoretical issues behind determining whether an edge is safe or not.

Let S be a subset of vertices S _ V. A cut (S, V − S) is just a partition of vertices into two disjoint subsets. An edge (u, v) crosses the cut if one endpoint is in S and the other is in V − S. Given a subset of edges A, a cut respects A if no edge in A crosses the cut. It is not hard to see why respecting cuts are important to this problem. If we have computed a partial MST and we wish to know which edges can be added that do not induce a cycle in the current MST, any edge that crosses a respecting cut is a possible candidate.
Ref: Handouts Page No.143

What are two cases for computing

Answer:-
There are two cases for computing Lij the match case if ai = bj , and the mismatch case if ai 6= bj . In the match case, we do the following:

and in the mismatch case, we do the following:


Ref: Handouts Page No.143

More CS502 files

All CS502 files · Midterm Prep 2026 · MCQs Bank