cs301 quiz 2 file.pdf

Verified academic study resource for CS301 (Data Structures) under the Computer Science at Virtual University of Pakistan. This PDF document (Live Quiz Dumps & Solved Objective Bank) covers Quizzes & Objective Exam Scope spanning approximately 180 pages across 8 curriculum modules, and is indexed for student examination review with instant in-browser preview and 100% free direct download.

Course
CS301 – Data Structures
Faculty
Computer Science
Format
PDF
Type
Quiz
Coverage
Quizzes & Objective Exam Scope

Quiz questions often repeat with modified parameter values in both Midterm and Final exams. Practice with our 45-second timed simulator to master exam pacing.

What this file covers — CS301 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 cs301 quiz 2 file.pdf for free?

You can preview and download "cs301 quiz 2 file.pdf" (CS301 PDF, ~180 pages) directly from the MIHORA VU Study Library (https://study.mihora.tech/doc/cs301-quiz-2-file-pdf-2) with 100% free high-speed downloads and zero registration requirements.

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

This document covers Quizzes & Objective Exam Scope 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 CS301 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 CS301 solved past papers and handouts verified for 2026 exams?

Yes. All CS301 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

CS301 – Data Structures                                 Lecture No. 3633
___________________________________________________________________

Data Structures

Lecture No. 3633

Reading Material
Data Structures and Algorithm Analysis in C++                       Chapter. 6, 8
                                                                    6.3, 8.1

Summary
              Priority Queue Using Heap
              The Selection Problem
              Heap Sort
              Disjoint Set ADT
              Equivalence Relations

Priority Queue Using Heap
InAs discussed in the previous lecture, we discussed a lot about buildHeap.generally
prefer to employ the buildHeap to construct If we have all the data available thenheap
instead of using insert we can use buildHeap to construct heap. buildHeap is optimized as
compared to insert method because it takes lesserthan Nlog2N time. We also proved a
theorem that if the number of linkes in the tree are counted then the sum of heights of the
nodes is N-h-1. We have been iteratinglot of times that the best use of heap is
implementing priority queues. Lets try to develop a class of priority queue using heap.
You might be remembering, when we did bank simulation, weused a priority queue but
that was implementedusing an array. Now, we will implement the same queue using a
heap. We will modify the same code to use heap instead of any array. The interface (.h
file) will remain the same but the implementation (.cpp file) will be changed. As .cpp file
will change, so let’s see the .cpp code below:

The first line is including a file Event.cpp, this is containing all the events used for
simulation. We are including .cpp files here as we have used templates of C++. At the
second line, we have included heap.cpp. In the third line, we are defining a constant
PQMAX, declaring the maximum size of the priority queue to be 30. In line 4, class
PriorityQueue is declared. public keyword is given at line 6 indicating that all class
members below will be of public scope. Line 7 is starting the class constructor’s
definition. At line 9, a new heap object is being created, this object is a collection of
Event type objects and the number of elements in the collection is PQMAX. The address
(pointer) of the newly created heap is stored in the heap object pointer. The heap is a

                                                                             Page 1 of 155

CS301 – Data Structures                                 Lecture No. 3633
___________________________________________________________________
private pointer variable of PriorityQueue class. Next comes the destructor of the class,
where we are deleting (deallocating the allocated resources) the pointer variable heap.
Next isthe remove method that was sometimes, named as dequeue in our previous
lectures. remove method is returning an Event pointer. Inside remove, the first statement
at line 19 is an if-condition; which is checking whether heap is not empty. If the
condition is true (i.e. the heap is not empty), a local variable (local to the block) Event*
variable e is declared. In the next line at line 22, we are calling deleteMin method to
delete (remove) an element from the heap, the removed element is assigned to the passed
in parameter pointer variable e. You might have noticed already that in this version of
deleteMin, the parameter is being passed by pointer, in the previous implementation we
used reference. In the next line, the retrieved value is returned, the function returns by
returning the pointer variable e. But if the heap was empty when checked at line 19, the
control is transferred to the line 25. At line 25, a message is displayed to show that the
heap is empty and the next line returns a NULL pointer.
It is important to understand one thing that previously when we wrote the array based
remove method. We used to take an element out from the start of the array and shifted the
remaining elements to left. As in this implementation, we are using heap, therefore, all
the responsibilities of maintaining the heap elements lie with the heap. When the
deleteMin() is called, it returns the minimum number.

????

We see the insert method now line by line. It is accepting a pointer type parameter of
type Event. As the heap may become full if we keep on inserting elements into it,
therefore, the first line inside the insert function is checking if the heap has gone full. If
the heap is not full then the if-block is entered. At line 33 inside the if-block, an element
that is passed as a parameter to insert method of heap is inserted into the queue by calling
the insert method of heap. This insert call will internally perform percolate up and down
operations to place the new element at its correct position. The returned value 1 indicates
the successful insertion in the queue. If the heap has gone full then a message is displayed
that ‘insert queue is full’. Note that we have used the word queue not heap in that
message. It has to that way otherwise the users of the PriorityQueue class are unaware of
the internal representation of the queue (whether it is implemented using a heap or an
array). Next line is returning 0indicating that the insert operation was not successful.
Below to insert, we have full() method. This method returns an int value. Internally, it is
calling isFull() method of heap. The full() method returns whatever is returned by the
isFull() method of heap. Next is length() method, as the size of heap is also the size of the
queue, therefore, length() is internally calling the getSize() method of heap.

In this new implementation the code is better readable than the PriorityQueue’s
implementation with array. You must be remembering when we implemented the
PriorityQueue with an array, at each insertion in the if we have all the required data.
buildHeap is optimized as compared to insert method as it takes lesser time than Nlog2N .
In the previous discussion, we had proved a theorem that if the number of links in the tree

More CS301 files

All CS301 files · Midterm Prep 2026 · MCQs Bank