The document outlines the terminal examination for the Data Structure and Algorithm course at COMSATS University, Islamabad, scheduled for May 8, 2023. It includes a case study for implementing an online seat reservation system for a transport company, detailing the data structures needed, along with questions on implementing a priority queue using stacks and algorithms for handling binary search trees. The exam consists of various tasks requiring conceptual diagrams, data structures, and pseudocode or C language code.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0 ratings0% found this document useful (0 votes)
4 views2 pages
SP23 MidTerm
The document outlines the terminal examination for the Data Structure and Algorithm course at COMSATS University, Islamabad, scheduled for May 8, 2023. It includes a case study for implementing an online seat reservation system for a transport company, detailing the data structures needed, along with questions on implementing a priority queue using stacks and algorithms for handling binary search trees. The exam consists of various tasks requiring conceptual diagrams, data structures, and pseudocode or C language code.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 2
COMSATS University, Islamabad
Islamabad Campus
Department of Computer Science
TERMINAL EXAMINATION - SPRING 2023
AVDS) Date: May 08, 2023
Data Structure and Algorithm Total Marks: 50
90 mints Section: CS -%
cl r. Inayat Ur-Rehman/ Mr. Mustafa Khattak’ Dr, Zobia Rehman’ Dr. Nusrat
Shaheen Mr. Syed Ahmed “ Registration Number: _¢B).2--R $52
a
Marks: 20
QUESTION 1 CLO-1; Empiov linear data structures to solve computing problems.
Case study 1: A major transport company wants to implement an advanced online seat reservation system. The
company operates between Islamabad and Karachi, having stops/terminals in six major cities (say Mianwali,
Bhakkar, Multan, Bahawalpur, Sukhar, and Hyderabad). The buses leave from main terminals at 9:00 am,
12noon and 9 pm. Clients/pa: S may request to reserve a maximum of four seats against a single request,
however, the passenger with maximum number of seats request will be given higher priority (like if a person a
requests 4 seats other person requests 3 seats then 4 will be of higher priority) . Requests may be cancelled or
changed any time before confirmation without any penalty, However, after confirmation (1 hour before leaving)
23% penalty will be imposed. The seating capacity of a bus is 40, Seats will be allocated based on FCFS keeping
in view the following quots.
2) First erved. pi-isuanubed, isiamabad-Karachi), —— —
). Next 10 seats are reserved for starting terminal vo 2nd last terminal.
c). Next 5 seats are reserved for starting terminal to 3rd last terminal.
€). Next 4 seats are reserved for starting terminal t9 4th last terminal.
e). Next 3 seats are reserved for starting terminal to Sth last terminal.
f), Next 2 seats are reserved for starting terminal io 6th last terminal.
g). __ Last seat is reserved for starting terminal to 7th last terminal.
Following rules will also be applicable: u
i). A waiting queue will be maintained for each te-minal. ~~
Request of last terminal will bé of higher priority then n-Ith terminal.
Requests for N scats will bo preferred over the requests for, N-] and so on.
iv). Incase sufficient requests are not available as per quota specified above, next higher level requests will
: be entertained to fill up the seats.
v). Waiting requests will automatically be promoted to the neat higher level if they are not entertained
from the last two hours,
To efficiently implement the above case scenario, suggest a suitable combination of data structures by:
1) What Data Structures you will prefer to do for which specific task elaborate with conceptual
diagram. [4 Marks}
2) Write the structure with required data members/global variables along with their types. [4 Marks]#
3) _ Write the pseudocode/C language code of required functions (ADT) along with their pre-conditions
and post-conditions [12 Marks]_-CLO-1 === Marks: 15
QUESTION 2: =
Assume that you have already implemented the ADT Stack. By using that (don’t reinvent the
wheel), write a program to implement the Priority Queue by using stack.
QUESTION 3: == CLO-2: Use non-linear data structures to solve computing problems. Marks:15 (7.5+7.5)
Part-I: Write an optimally efficient algorithm to find the successor (next greater value of node)
of a given node n in a BST.
Part-2: Using the above defined method, write an algorithm for deleting a node d from BST when
neither of d’s subtrees is empty. There may be a case when there is a right subtree of successor.