CS502- Midterm Solved Subjective With References by Moaaz.docx
Verified academic study resource for CS502 (Fundamentals of Algorithms) under the Computer Science at Virtual University of Pakistan. This DOC document (Midterm Solved Past Paper & Revision File compiled by Moaaz Siddhu) 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
- DOC
- Type
- Midterm
- Coverage
- Mid-Term Exam Scope (Lectures 1 to 22)
- Compiled by
- Moaaz Siddhu
- 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 With References by Moaaz.docx for free?
You can preview and download "CS502- Midterm Solved Subjective With References by Moaaz.docx" (CS502 DOC, ~240 pages) directly from the MIHORA VU Study Library (https://study.mihora.tech/doc/cs502-midterm-solved-subjective-with-references-by-moaaz-docx) 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
CS502 – Midterm Spring 2013 (26 May-05 June) How would you modify QUICKSORT to sort into non-increasing order? Answer: - Click here for detail To make QUICKSORT sort in non-increasing order we must modify PARTITION. Q- We can avoid unnecessary repetitions for recursive calls? Answer: - (Page 74) We can avoid these 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. Q-Write a pseudo code Fibonacci With memorization? -- (3) Answer: - (Page 74) MEMOFIB(n) 1 if (n < 2) 2 then return n 3 if (F[n] is undefined) 4 then F[n] MEMOFIB(n − 1) + MEMOFIB(n − 2) 5 return F[n] Spelling correction in edit distance? 3 marks Answer: - (Page 76) If a text contains a word that is not in the dictionary, a ‘close’ word, i.e. one with a small edit distance, may be suggested as a correction. Most word processing applications, such as Microsoft Word, have spelling checking and correction facility. When Word, for example, finds an incorrectly spelled word, it makes suggestions of possible replacements. Bubble sort? Answer: - (Page 39) Scan the array. Whenever two consecutive items are found that are out of order, swap them. Repeat until all consecutive items are in order. What is the worst case running time for the Quick sort? What simple change is required in the algorithm to preserve its linear expected running time and makes it worst case time Θ(n log n) Answer: - (Page 49) Worst case running time is O (n). The simple change which can change the running time of the edit distance algorithm is the number of entries n2. CS502 – Midterm Spring 2013 (26 May-05 June) QUICK, HEAP, COUNTING, MERG KA TABLE KA JIS ME STABLE OR IN-PLACE BTANEY THE 5 MARKS Answer: Page 54 IN Place Stable Selection Sort Quick Sort Heap sort Bubble sort Bubble sort Insertion Sort Insertion Sort Merge sort Counting sort ADIT DISTANCE KI 3 APPLICATION K NAME BTANEY THE 3 MARKS Answer: - (Page 76) Spelling Correction Plagiarism Detection Speech Recognition MEMOIZATION KI DIFINATION THI 2 MARKS Answer: - Click here for detail Memoization is an optimization technique used primarily to speed up computer programs by having function calls avoid repeating the calculation of results for previously processed inputs WORS CASE OR AVERAGE CASE DEFINE KRNE THE 2 MARKS Answer: - (Page 13) Worst-case time is the maximum running time over all (legal) inputs of size n Average-case time is the average running time over all inputs of size n. CS502 – Midterm Spring 2013 (26 May-05 June) Write Essential constraint of Counting sort. Answer: Essential constraint for the counting sort is that numbers to be sorted must be small integers i.e., 1…..k where k is small. What are total numbers of entries in matrix for edit distance? Answer: - (Page 84) There are O(n2) entries in the matrix. Each entry E(i, j) takes O(1) time to compute. The total running time is O(n2). WHAT IS the necessary assumption for average case analysis quick sort? Answer: - (Page 50) Average case depends on some assumption about the distribution of inputs. However, in the case of quicksort, the analysis does not depend on the distribution of input at all. It only depends upon the random choices of pivots that the algorithm makes Suggest & describe modifications of the implementation of "Quick sort" that will improve its performance? Answer: - (Page 76) CS502 – Midterm Spring 2013 (26 May-05 June) Q1 : How we Heapify? Answer: If an element in the Heap is not at its proper place means it is violating the Heap Order, the Heapify procedure is used to fix it and place it at its proper position. In Heapify, we recursively swap the element with its larger one child and stop at a stage when this element is larger than both of its children or it becomes the leaf node. Q2 : Describe Heap sort algorithm? Answer: - (Page 43) HEAPIFY( array A, int i, int m) 1 l LEFT(i) 2 r RIGHT(i) 3 max i 4 if (l _ m)and(A[l] > A[max]) 5 then max l 6 if (r _ m)and(A[r] > A[max]) 7 then max r 8 if (max 6= i) 9 then SWAP(A[i],A[max]) 10 HEAPIFY(A,max,m) Q3 : How many elements are in matrix of edit distance? Answer: Rep Q6 : suggest and describe one modification of implementing quick sort? 5marks CS502 – Midterm Spring 2013 (26 May-05 June) Edit Distance in Speech Recognition Answer: - (Page 77) Speech Recognition Algorithms similar to those for the edit-distance problem are used in some speech recognition systems. Find a close match between a new utterance and one in a library of classified utterances. What is sorting? Describe slow running sorting algorithms. 5 marks Answer: - (Page 39) Sorting is any process of arranging items in some sequence and/or in different sets, and accordingly, 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]. These algorithms are easy to implement. But they run in _(n2) time in the worst case Catalan Numbers and their formula 3 marks Answer: - (Page 85) Catalan numbers are related the number of different binary trees on n nodes. Catalan number is given by the formula: CS502 – Midterm Spring 2013 (26 May-05 June) Q1.Heap Sort , Counting Sort , Quick Sort ,Merge Sort , in ,table ,And required to tell , which is inplace Algorithm and stable ? Marks 5 Answer: rep Q2 . Suggest that how can make better improvement in Quick Sort algorithm .Marks 5 Answer: - (Page 54)
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)