CS301-lec10.ppt
Verified academic study resource for CS301 (Data Structures) under the Computer Science at Virtual University of Pakistan. This PPT 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
- CS301 – Data Structures
- Faculty
- Computer Science
- Format
- PPT
- Type
- Handout
- Coverage
- Complete Course Handouts (Lectures 1 to 45)
- Tags
- SLIDES
Virtual University examiners construct 100% of objective MCQs and subjective marking schemes directly from the official CS301 handouts.
What this file covers — CS301 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)
- Object-Oriented Paradigms: Classes & Data Abstraction — Lectures 23 to 29 (Pages 281 to 360). 16% Final-Term Marks (Core OO Concepts)
- Inheritance Hierarchies & Dynamic Polymorphism — Lectures 30 to 36 (Pages 361 to 435). 20% Final-Term Marks (Virtual Functions & V-Tables)
- Templates, Standard Library & Persistent File I/O — Lectures 37 to 41 (Pages 436 to 510). 14% Final-Term Marks (Generic Code & Streams)
- 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-lec10.ppt for free?
You can preview and download "CS301-lec10.ppt" (CS301 PPT, ~450 pages) directly from the MIHORA VU Study Library (https://study.mihora.tech/doc/cs301-lec10-ppt) with 100% free high-speed downloads and zero registration requirements.
What syllabus chapters and lectures are covered in this CS301 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 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
Lecture No.10
Data Structures
Dr. Sohail Aslam
Simulation of a Bank
A customer enters the bank at a specific
time (t1) desiring to conduct a transaction.
Any one of the four tellers can attend to
the customer.
The transaction (withdraw, deposit) will
take a certain period of time (t2).
If a teller is free, the teller can process the
customer’s transaction immediately and
the customer leaves the bank at t1+t2.
Simulation of a Bank
It is possible that none of the four tellers is
free in which case there is a line of
customers are each teller.
An arriving customer proceeds to the back
of the shortest line and waits for his turn.
The customer leaves the bank at t2 time
units after reaching the front of the line.
The time spent at the bank is t2 plus time
waiting in line.
Simulation of a Bank
teller 1 teller 2 teller 3 teller 4
Simulation of a Bank
teller 1 teller 2 teller 3 teller 4
Simulation of a Bank
teller 1 teller 2 teller 3 teller 4
Simulation of a Bank
teller 1 teller 2 teller 3 teller 4
Simulation of a Bank
teller 1 teller 2 teller 3 teller 4
Simulation of a Bank
teller 1 teller 2 teller 3 teller 4
Simulation of a Bank
teller 1 teller 2 teller 3 teller 4
Simulation Models
Two common models of simulation are
time-based simulation and event-based
simulation.
In time-based simulation, we maintain a
timeline or a clock.
The clock ticks. Things happen when the
time reaches the moment of an event.
Timeline based Simulation
Consider the bank example. All tellers are free.
Customer C1 comes in at time 2 minutes after
bank opens.
His transaction (withdraw money) will require 4
minutes.
Customer C2 arrives 4 minutes after the bank
opens. Will need 6 minutes for transaction.
Customer C3 arrives 12 minutes after the bank
opens and needs 10 minutes.
Timeline based Simulation
Events along the timeline:
Time (minutes)
0 1 2 3 4 5 6 7 8 10 11 12 13 14 15
C1 in C1 out
C2 in C2 out
C3 in
Timeline based Simulation
We could write a main clock loop as follows:
clock = 0;
while( clock <= 24*60 ) { // one day
read new customer;
if customer.arrivaltime == clock
insert into shortest queue;
check the customer at head of all four queues.
if transaction is over, remove from queue.
clock = clock + 1;
}
Event based Simulation
Don’t wait for the clock to tic until the next
event.
Compute the time of next event and
maintain a list of events in increasing
order of time.
Remove a event from the list in a loop and
process it.
Event based Simulation
Events
Time (minutes)
0 1 2 3 4 5 6 7 8 10 11 12 13 14 15
C1 in C1 out
C2 in C2 out
C3 in
Event 1: 2 mins C1 in
Event 2: 4 mins C2 in
Event 3: 6 mins C1 out
Event 4: 10 mins C2 out
Event 5: 12 mins C3 in
Event based Simulation
Maintain a queue of events.
Remove the event with the earliest time
from the queue and process it.
As new events are created, insert them in
the queue.
A queue where the dequeue operation
depends not on FIFO, is called a priority
queue.
Event based Bank Simulation
Development of the C++ code to carry out
the simulation.
We will need the queue data structure.
We will need the priority queue.
Information about arriving customers will
be placed in an input file.
Each line of the file contains the items
(arrival time,transaction duration)
Arriving Customers’ File
Here are a few lines from the input file.
00 30 10 <- customer 1
00 35 05 <- customer 2
00 40 08
00 45 02
00 50 05
00 55 12
01 00 13
01 01 09
“00 30 10” means Customer 1 arrives 30 minutes after bank opens
and will need 10 minutes for his transaction.
“01 01 09” means customer arrives one hour and one minute after
bank opens and transaction will take 9 minutes.
Simulation Procedure
The first event to occur is the arrival of the
first customer.
This event placed in the priority queue.
Initially, the four teller queues are empty.
The simulation proceeds are follows:
When an arrival event is removed from the
priority queue, a node representing the
customer is placed on the shortest teller
queue.
Simulation Procedure
If that customer is the only one on a teller
queue, a event for his departure is placed
on the priority queue.
At the same time, the next input line is
read and an arrival event is placed in the
priority queue.
When a departure event is removed from
the event priority queue, the customer
node is removed from the teller queue.
Simulation Procedure
The total time spent by the customer is computed:
it is the time spent in the queue waiting and the
time taken for the transaction.
This time is added to the total time spent by all
customers.
At the end of the simulation, this total time divided
by the total customers served will be average time
spent by customers.
The next customer in the queue is now served by
the teller.
A departure event is placed on the event queue.
Code for Simulation
#include <iostream>
#include <string>
#include <strstream.h>
#include "Customer.cpp"
#include "Queue.h"
#include "PriorityQueue.cpp"
#include "Event.cpp"
Queue q[4]; // teller queues
PriorityQueue pq; //eventList;
int totalTime;
int count = 0;
int customerNo = 0;
Code for Simulation
main (int argc, char *argv[])
{
Customer* c;
Event* nextEvent;
More CS301 files
- CS301 & CS301P Short Notes By Qalb-e-Momin .pdf (PDF · Handout)
- CS301 Handouts (Updated) by MS.pdf (PDF · Handout)
- CS301 Handouts by MS S26.pdf (PDF · Handout)
- CS301 Handouts by MS.pdf (PDF · Handout)
- CS301 Handouts by MS.pdf (PDF · Handout)
- CS301 HighLight Notes.pdf (PDF · Handout)
- CS301 Highlight Handout By Vu Topper RM.pdf (PDF · Handout)
- CS301 Highlight Handout By Vu Topper RM.pdf (PDF · Handout)