CS502 MidTerm Solved Subjective mega file by Saifi.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
- Type
- Midterm
- Coverage
- Mid-Term Exam Scope (Lectures 1 to 22)
- Tags
- SUBJECTIVE, SOLVED, 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
- Core Architecture, Syntax & Primitive Data Structures — Lectures 1 to 6 (Pages 1 to 65). 15% Objective Marks (8–10 MCQs)
- Conditional Branching, Loops & Logical Control Flow — Lectures 7 to 12 (Pages 66 to 140). 18% Exam Marks (MCQs + 2-Mark Short Questions)
- Memory Management, Pointers, Arrays & Functions — Lectures 13 to 18 (Pages 141 to 215). 22% Exam Marks (High Yield for Midterms)
- 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 MidTerm Solved Subjective mega file by Saifi.pdf for free?
You can preview and download "CS502 MidTerm Solved Subjective mega file by Saifi.pdf" (CS502 PDF, ~240 pages) directly from the MIHORA VU Study Library (https://study.mihora.tech/doc/cs502-midterm-solved-subjective-mega-file-by-saifi-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
Cs 502 Subjective Mid Term
Prepared by
Saif
For Past Papers visit:
http://vupkpastpapers.blogspot.com
Remember me in your prayers
MID TERM EXAMINATION
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
Page #158
Floyd algorithm
A graph analysis algorithm for finding shortest paths in a weighted graph with positive or
negative edge weights. A single execution of the algorithm will find the lengths (summed
weights) of the shortest paths between all pairs of vertices.
write suedo code of dijkstra algorithm? 5marks
Page #156
Compare bellman ford algorithm with dijikstr's algorithm. Also give the time complexity
of bellman ford algorithm (3 marks)
Dijkstra‟s single-source shortest path algorithm works if all edges weights are non-negative and
there are no negative cost cycles. Bellman-Ford allows negative weights edges and no negative
cost cycles. The algorithm is slower than Dijkstra‟s, running in _(VE) time. Like Dijkstra‟s
algorithm, Bellman-Ford is based on performing repeated relaxations. Bellman-Ford applies
relaxation to every edge of the graph and repeats this V − 1 times.
Page #159
psedo code of timestamp DFS
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)
Page #126
variants of shortest path solution
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.
Page #153
Total running time of edit distance
The total running time is _(n2).
Page #84
Question No: 49 ( Marks: 5 )
What is the cost of the following graph?
Cost =33
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.
abce
bad
cadef
dbcf
eacf
fcde
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 )More CS502 files
- CS502 MIDTERM FILE 1 SOLVED BY TEAM HADI-1.pdf (PDF · Midterm)
- CS502 MIDTERM FILE 1 SOLVED BY TEAM HADI.pdf (PDF · Midterm)
- CS502 MIDTERM FILE 1 SOLVED BY TEAM HADI.pdf (PDF · Midterm)
- CS502 MIDTERM FILE 1 SOLVED BY TEAM HADI.pdf (PDF · Midterm)
- CS502 MIDTERM FILE 10 SOLVED BY TEAM HADI.pdf (PDF · Midterm)
- CS502 MIDTERM FILE 2 SOLVED BY TEAM HADI-1.pdf (PDF · Midterm)
- CS502 MIDTERM FILE 2 SOLVED BY TEAM HADI.pdf (PDF · Midterm)
- CS502 MIDTERM FILE 2 SOLVED BY TEAM HADI.pdf (PDF · Midterm)