CS502 Subjective file for Mid Term.pdf

Verified academic study resource for CS502 (Fundamentals of Algorithms) under the Computer Science at Virtual University of Pakistan. This PDF document (Midterm Solved Past Paper & Revision File) covers Mid-Term Exam Scope (Lectures 1 to 22) spanning approximately 240 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
PDF
Type
Midterm
Coverage
Mid-Term Exam Scope (Lectures 1 to 22)
Tags
SUBJECTIVE, MIDTERM

Focus on core definitions and repeated MCQs from Lectures 1–22. Remember that scoring in the First Half builds your safety buffer toward the mandatory 20% Two-Half passing rule in CS502.

What this file covers — CS502 syllabus roadmap

  1. Core Architecture, Syntax & Primitive Data Structures — Lectures 1 to 6 (Pages 1 to 65). 15% Objective Marks (8–10 MCQs)
  2. Conditional Branching, Loops & Logical Control Flow — Lectures 7 to 12 (Pages 66 to 140). 18% Exam Marks (MCQs + 2-Mark Short Questions)
  3. Memory Management, Pointers, Arrays & Functions — Lectures 13 to 18 (Pages 141 to 215). 22% Exam Marks (High Yield for Midterms)
  4. Midterm Consolidation, Strings & Algorithm Synthesis — Lectures 19 to 22 (Pages 216 to 280). Midterm Exam Culmination (Lectures 1–22 Scope)

Frequently asked questions

Where can I download CS502 Subjective file for Mid Term.pdf for free?

You can preview and download "CS502 Subjective file for Mid Term.pdf" (CS502 PDF, ~240 pages) directly from the MIHORA VU Study Library (https://study.mihora.tech/doc/cs502-subjective-file-for-mid-term-pdf) with 100% free high-speed downloads and zero registration requirements.

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

This document covers Mid-Term Exam Scope (Lectures 1 to 22) across 4 distinct lecture units (Lectures 1 to 6, Lectures 7 to 12, Lectures 13 to 18, Lectures 19 to 22), 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

How we can avoid unnecessary repetitions for recursive calls?
We can avoid this unnecessary repetitions by writing down the results of recursive
calls and looking them up again if we need them later. This process is called
memoization
Question No: 19 ( Marks: 2 )
Draw the cost table for chain matrix multiplication problem with initial state.
(A1)(A2A3A4 . . .An)
or (A1A2)(A3A4 . . .An)
or (A1A2A3)(A4 . . .An)
......
or (A1A2A3A4 . . .An−1)(An)

What are Catalan numbers? Give the formula.
PAGE NO. 85 ON PDF
Heap sort Algorithm

Page #41
BFS pseudo code in graph
Start with s and visit its adjacent nodes. Label them with distance 1. Now consider the neighbours of
neighbours of s. These would be at distance 2. Now consider the neighbours of neighbours of
neighbours of s. These would be at distance 3. Repeat this until no more unvisited neighbours left to
visit.

heapify
There is one principal operation for maintaining the heap property. It is called Heapify. The idea is that
we are given an element of the heap which we suspect may not be in valid heap order, but we assume
that all of other the elements in the subtree rooted at this element are in heap order. In particular this
root element may be too small. To fix this we “sift” it down the tree by swapping it with one of its
children. Which child? We should take the larger of the two children to satisfy the heap ordering
property. This continues recursively until the element is either larger than both its children or until its
falls all the way to the leaf level.

Polynomial time algorithm
A polynomial time algorithm is any algorithm that runs in O(nk) time. A problem is solvable in
polynomial time if there is a polynomial time algorithm for it.

What is a run time analysis and its two criteria

The main purpose of our mathematical analysis will be measuring the execution time. The running time
of an implementation of the algorithm would depend upon the speed of the computer, programming
language, optimization by the compiler etc. Two criteria for measuring running time are worst-case time
and average-case time.

Worst-case time is the maximum running time over all (legal) inputs of size n. Let I denote an input
instance, let |I| denote its length, and let T(I) denote the running time of the algorithm on input I. Then

Average-case time is the average running time over all inputs of size n. Let p(I) denote the probability of
seeing this input. The average-case time is the weighted sum of running times with weights being the
probabilities:

We will almost always work with worst-case time. Average-case time is more difficult to compute; it is
difficult to specify probability distribution on inputs. Worst-case time will specify an upper limit on the
running time.

Page #13
Dijkstra algorithm correctness criteria two conditions

Question No: 50 ( Marks: 5 )

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
If any of the vertex do not have any adjacent vertices, It is shown in the list a single entity.

Question No: 48 ( Marks: 3 )

Recursive explanation of dynamic programming.

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.

Question No: 28 ( Marks: 2 )

Differentiate between back edge and forward edge.

Back edge: (u, v) where v is an ancestor of u in the tree.

Forward edge: (u, v) where v is a proper descendent of u in the tree.

Question No: 29 ( Marks: 2 )

How the generic greedy algorithm operates in minimum spanning tree?

A generic greedy algorithm operates by repeatedly adding any safe edge to the current spanning tree.

Question No: 30 ( Marks: 2 )

What are two cases for computing assuming we already have the previous matrix               using Floyed-
Warshall algorithm?

There are two basic cases:

1. Don’t go through vertex k at all.

2. Do go through vertex k.

Question No: 31 ( Marks: 3 )

Describe Minimum Spanning Trees Problem with examples.

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.

Question No: 32 ( Marks: 3 )

What is decision problem, also explain with example?

A problem is called a decision problem if its output is a simple “yes” or “no” (or you may this of this as
true/false, 0/1, accept/reject.)

Question No: 33 ( Marks: 3 )

Prove that the generic TRAVERSE (S) marks every vertex in any connected graph exactly once and the set
of edges (v, parent (v)) with parent (v) ¹F form a spanning tree of the graph.

First, it should be obvious that no vertex is marked more than once. Clearly, the algorithm marks s. Let v
6= s be a vertex and let s ! · · · ! u ! v be a path from s to v with the minimum number of edges.

Page #125 lemma

Question No: 35 ( Marks: 5 )

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]

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

More CS502 files

All CS502 files · Midterm Prep 2026 · MCQs Bank