CS502 - Final term solved Subjective with references by Moaaz.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 compiled by Moaaz Siddhu) 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)
Compiled by
Moaaz Siddhu
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 term solved Subjective with references by Moaaz.doc for free?

You can preview and download "CS502 - Final term solved Subjective with references by Moaaz.doc" (CS502 DOC, ~320 pages) directly from the MIHORA VU Study Library (https://study.mihora.tech/doc/cs502-final-term-solved-subjective-with-references-by-moaaz-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 algorithm
Solved Subjective
From Final Term Papers

10 July,2013

MC100401285
Moaaz.pk@gmail.com          Mc100401285@gmail.com
PSMD01

CS502 – Final term (Fall 2012)

 Q No.1		Suppose you could prove that an NP-complete problem cannot be solved in polynomial time. What would be the consequence?
Answer: Page 173
If we can solve a problem in polynomial time, we can certainly verify the solution in polynomial time. More formally, we do not need to see a certificate to solve the problem; we can solve it in polynomial time anyway.
However, it is not known whether P = NP. It seems unreasonable to think that this should be so. Being able to verify that you have a correct solution does not help you in finding the actual solution. The belief is that P 6= NP but no one has a proof for this.

Q No.3 Describe Dijkstra’s algorithm working?
Answer: (Page 154)
Dijkstra’s algorithm is a simple greedy algorithm for computing the single-source shortest-paths to all other vertices. Dijkstra’s algorithm works on a weighted directed graph G = (V, E) in which all edge weights are non-negative, i.e., w(u, v) _ 0 for each edge (u, v) 2 E.
Negative edges weights maybe counter to intuition but this can occur in real life problems. However, we will not allow negative cycles because then there is no shortest path. If there is a negative cycle between, say, s and t, then we can always find a shorter path by going around the cycle one more time.

Q No.8   Explain the topological sort?
Answer: (Page 133)
A topological sort of a DAG is a linear ordering of the vertices of the DAG such that for each edge (u, v),
u appears before v in the ordering. Computing a topological ordering is actually quite easy, given a DFS of the DAG. For every edge (u, v) in a DAG, the finish time of u is greater than the finish time of v (by the lemma). Thus, it suffices to output the vertices in the reverse order of finish times.



Q No.5 In the solution of edit distance technique, please describe two solution  given
(i) MATHS (ii) ARTS
Answer: (Page 77)

Q No.7  Explain the following two basic cases according to Floyd-Warshall Algorithm,
1. Don’t go through vertex k at all.
2. Do go through vertex k.

Answer: (Page 162)



Q No.6Variants of shortest path solution briefly?
Answer: (Page 153)
There are a few variants of the shortest path problem.
Single-source shortest-path problem: Find shortest paths from a given (single) source vertex s 2 V to every other vertex v 2 V in the graph G.
Single-destination shortest-paths problem: Find a shortest path to a given destination vertex t from each vertex v. We can reduce the this problem to a single-source problem by reversing the direction of each edge in the graph.
Single-pair shortest-path problem: Find a shortest path from u to v for given vertices u and v. If we solve the single-source problem with source vertex u, we solve this problem also. No algorithms for this problem are known to run asymptotically faster than the best single-source algorithms in the worst case.
All-pairs shortest-paths problem: Find a shortest path from u to v for every pair of vertices u and v.
Although this problem can be solved by running a single-source algorithm once from each vertex, it can usually be solved faster.

CS502 – Final term (Fall 2012)

What is the Running time of Bellman Ford Algorithm?
Answer:  Click here for detail
Bellman–Ford runs in O(|V|·|E|) time,

Define Forward Edge from ancestor to descendent (u, v) where v is a proper descendent of u in the tree.
Answer: (Page 130)
For a forward edge (u, v), v is a descendent of u and so v’s start-finish interval is contained within u’s implying that v has an earlier finish time. For a cross edge (u, v) we know that the two time intervals are disjoint. When we were processing u, v was not white (otherwise (u, v) would be a tree edge), implying that v was started before u. Because the intervals are disjoint, v must have also finished before u

What is the common problem in communications networks and circuit designing?
Answer: (Page 142)
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


Q  pseudo code of timestamp  DFS
Answer: (Page 126)
DFS(G)
1 for (each u 2 V)
2 do color[u]   white
3 pred[u]   nil
4 time   0
5 for each u 2 V
6 do if (color[u] = white)
7 then DFSVISIT(u)

Prove the following lemma,
Lemma: Given a digraph G = (V, E), consider any DFS forest of G and consider any edge (u, v) ∈ E. If this edge is a tree, forward or cross edge, then f[u] > f[v]. If this edge is a back edge, then f[u] ≤ f[v]
Answer: (Page 130)
Proof: For the non-tree forward and back edges the proof follows directly from the parenthesis lemma. For example, for a forward edge (u, v), v is a descendent of u and so v’s start-finish interval is contained within u’s implying that v has an earlier finish time. For a cross edge (u, v) we know that the two time intervals are disjoint. When we were processing u, v was not white (otherwise (u, v) would be a tree edge), implying that v was started before u. Because the intervals are disjoint, v must have also finished before u.

How Kruskal's algorithm works ?
Answer: (Page 127)
Kruskal’s algorithm works by adding edges in increasing order of weight (lightest edge first). If the next edge does not induce a cycle among the current set of edges, then it is added to A. If it does, we skip it and consider the next in order. As the algorithm runs, the edges in A induce a forest on the vertices. The trees of this forest are eventually merged until a single tree forms containing all vertices.

Define according to Kruskal's algorithm
creat_set(u)
find_set(U)
union(u,v)
Answer: Page 147
Create-set(u): Create a set containing a single item u.
Find-set(u): Find the set that contains u
Union(u,v): merge the set containing u and set containing v into a common set.



CS502 – Final term (Fall 2012)

More CS502 files

All CS502 files · Midterm Prep 2026 · MCQs Bank