CS502 Subjective Important notes.pdf

Verified academic study resource for CS502 (Fundamentals of Algorithms) under the Computer Science at Virtual University of Pakistan. This PDF document (Official Lecture Handouts & Highlighted Notes) covers Complete Course Handouts (Lectures 1 to 45) spanning approximately 450 pages across 8 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
Handout
Coverage
Complete Course Handouts (Lectures 1 to 45)
Tags
SUBJECTIVE, IMPORTANT

Virtual University examiners construct 100% of objective MCQs and subjective marking schemes directly from the official CS502 handouts.

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)
  5. Object-Oriented Paradigms: Classes & Data Abstraction — Lectures 23 to 29 (Pages 281 to 360). 16% Final-Term Marks (Core OO Concepts)
  6. Inheritance Hierarchies & Dynamic Polymorphism — Lectures 30 to 36 (Pages 361 to 435). 20% Final-Term Marks (Virtual Functions & V-Tables)
  7. Templates, Standard Library & Persistent File I/O — Lectures 37 to 41 (Pages 436 to 510). 14% Final-Term Marks (Generic Code & Streams)
  8. 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 Subjective Important notes.pdf for free?

You can preview and download "CS502 Subjective Important notes.pdf" (CS502 PDF, ~450 pages) directly from the MIHORA VU Study Library (https://study.mihora.tech/doc/cs502-subjective-important-notes-pdf-2) with 100% free high-speed downloads and zero registration requirements.

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

This document covers Complete Course Handouts (Lectures 1 to 45) across 8 distinct lecture units (Lectures 1 to 6, Lectures 7 to 12, Lectures 13 to 18, Lectures 19 to 22, 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

       MUHAMMAD FAISAL 
                         MIT 4th Semester
        Al-Barq Campus (VGJW01) Gujranwala
               faisalgrw123@gmail.com
Reference Short Questions for MID TERM EXAMS
    CS502– Design and Analysis of Algorithms

Divide and Conquer Strategy                (Page#27)

The ancient Roman politicians understood an important principle of good algorithm
design (although they were probably not thinking about algorithms at the time). You
divide your enemies (by getting them to distrust each other) and then conquer them piece
by piece. This is called divide-and-conquer. In algorithm design, the idea is to take a
problem on a large input, break the input into smaller pieces, solve the problem on each
of the small pieces, and then combine the piecewise solutions into a global solution.
But once you have broken the problem into pieces, how do you solve these pieces? The
answer is to apply divide-and-conquer to them, thus further breaking them down. The
process ends when you are left with such tiny pieces remaining (e.g. one or two items)
that it is trivial to solve them. Summarizing, the main elements to a divide-and-conquer
solution are

Divide: the problem into a small number of pieces
Conquer: solve each piece by applying divide and conquer to it recursively
Combine: the pieces together into a global solution.

Selection Problem                 (Page#34)

Suppose we are given a set of n numbers. Define the rank of an element to be one plus the
number of elements that are smaller. Thus, the rank of an element is its final position if the set
is sorted. The minimum is of rank 1 and the maximum is of rank n.

Consider the set: {5, 7, 2, 10, 8, 15, 21, 37, 41}. The rank of each number is its position in the
sorted order.

position    1     2     3     4     5         6    7     8     9
Number      2     5     7     8     10        15   21    37    41

Sieve Technique              (Page#34)

The reason for introducing this algorithm is that it illustrates a very important special case of
divide-and-conquer, which I call the sieve technique. We think of divide-and-conquer as
breaking the problem into a small number of smaller subproblems, which are then solved
recursively. The sieve technique is a special case, where the number of subproblems is just 1.

The sieve technique works in phases as follows. It applies to problems where we are interested
in finding a single item from a larger set of n items.

Slow Sorting Algorithms               (Page#39)

There are a number of well-known slow O(n2) sorting algorithms. These include the following:

Bubble sort: Scan the array. Whenever two consecutive items are found that are out of order,
swap them. Repeat until all consecutive items are in order.

Insertion sort: Assume that A[1..i − 1] have already been sorted. Insert A[i] into its proper
position in this sub array. Create this position by shifting all larger elements to the right.

Selection sort: Assume that A[1..i − 1] contain the i − 1 smallest elements in sorted order.
Find the smallest element in A[i..n] Swap it with A[i].

Heaps         (Page#40)

A heap is a left-complete binary tree that conforms to the heap order. The heap order property:
in a (min) heap, for every node X, the key in the parent is smaller than or equal to the key in X.
In other words, the parent node has key smaller than or equal to both of its children nodes.
Similarly, in a max heap, the parent has a key larger than or equal both of its children Thus the
smallest key is in the root in a min heap; in the max heap, the largest is in the root.

Quicksort (Page#46)
Our next sorting algorithm is Quicksort. It is one of the fastest sorting algorithms known and is
the method of choice in most sorting libraries. Quicksort is based on the divide and conquer
strategy.

Here is the algorithm:

In-place, Stable Sorting         (Page#46)

An in-place sorting algorithm is one that uses no additional array for storage. A sorting
algorithm is stable if duplicate elements remain in the same relative position after sorting.

Bubble sort, insertion sort and selection sort are in-place sorting algorithms. Bubble sort and
insertion sort can be implemented as stable algorithms but selection sort cannot (without
significant modifications). Mergesort is a stable algorithm but not an in-place algorithm. It
requires extra array storage. Quicksort is not stable but is an in-place algorithm. Heapsort is an
in-place algorithm but is not stable.

Counting Sort          (Page#57)

We will consider three algorithms that are faster and work by not making comparisons.
Counting sort assumes that the numbers to be sorted are in the range 1 to k where k is small.
The basic idea is to determine the rank of each number in final sorted array.

Recall that the rank of an item is the number of elements that are less than or equal to it. Once
we know the ranks, we simply copy numbers to their final position in an output array.

Fibonacci Sequence              (Page#73)

Suppose we put a pair of rabbits in a place surrounded on all sides by a wall. How many pairs
of rabbits can be produced from that pair in a year if it is supposed that every month each pair
begets a new pair which from the second month on becomes productive? Resulting sequence is
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, . . . where each number is the sum of the two preceding numbers.

This problem was posed by Leonardo Pisano, better known by his nickname Fibonacci (son of
Bonacci, born 1170, died 1250). This problem and many others were in posed in his book
Liber abaci, published in 1202. The book was based on the arithmetic and algebra that
Fibonacci had accumulated during his travels. The book, which went on to be widely copied
and imitated, introduced the Hindu-Arabic place-valued decimal system and the use of Arabic
numerals into Europe. The rabbits problem in the third section of Liber abaci led to the
introduction of the Fibonacci numbers and the Fibonacci sequence for which Fibonacci is best
remembered today.

More CS502 files

All CS502 files · Midterm Prep 2026 · MCQs Bank