0% found this document useful (0 votes)
12 views

Assignment2 DSA

Uploaded by

saarimbangladesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Assignment2 DSA

Uploaded by

saarimbangladesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

THE SUPERIOR UNIVERSITY LAHORE

Assignment - 2
Semester: 3rd dd All
Section: Session: Fall 2024

Faculty of Computer Science and Information Technology QCH:


Subject: Data Structures & Algorithms Total Points: 40

DEADLINE: You have to Instructions:


submit the handwritten
assignments to your 1. Only handwritten assignments on A4 white papers will be accepted.
course tutors well 2. Explain everything asked in the tasks with full clarity.
before Thursday, 3. Ultimate purpose of the assignment is understanding, so your assignments will be
Instructor:
10-10-2024Muhammad Hassan Total Marks: 50
marked Viva Based. Concepts must be cleared and you must understand everything
ahead of 04:00pm. you write in the assignment.
4.
Task # CLO # Domain and BT Level Total Points
1 2 C3 5
2 2 C3 5
3 2 C3 5
4 2 C3 5
5 2 C3 5
6 2 C3 10
7 2 C3 5

Task 1: Event Management System with Waiting List


Build an Event Management System for a conference where people can register for the event.
If the event is fully booked, their registration is added to a waiting list using a singly linked list.
Each node contains the following information: Registration ID, Participant Name, Email, and
Status (Registered or Waiting).
Requirements:
• Two separate lists:
1. Registered List: For participants who have successfully registered for the event.
2. Waiting List: For participants who could not be registered and are on the waiting
list.
• The program should offer the following options:
1. Register a participant: If there is room in the event (maximum 50 participants),
add the participant to the registered list. Otherwise, add them to the waiting list.
2. Cancel a registration-by-Registration ID: If a participant cancels their
registration, remove them from the registered list. The first person on the waiting
list should then be moved to the registered list.
3. Display all registered participants: Traverse and display details of all registered
participants.
4. Display the waiting list: Traverse and display details of all participants on the
waiting list.
5. Search by email: Search for a participant using their email and display whether
they are registered or waiting.
6. Exit: Exit the program.

Task 2: Social Media Friend Suggestion System

Design a Friend Suggestion System for a social media platform using a singly linked list. Each
node in the list represents a user profile with attributes like User ID, Name, Number of Mutual
Friends, and Status (suggested/not suggested).

Requirements:

• Friend Suggestion Operations:


1. Add a new profile: Add a new user profile to the system with the necessary
details.
2. Display friend suggestions: Display all profiles that are marked as "suggested"
(not yet added as friends).
3. Add as friend: Search for a profile by User ID and mark it as "not suggested"
after the user accepts the friend suggestion.
4. Top N suggestions: Display the top N profiles with the highest number of mutual
friends.
5. Remove friend suggestion by User ID: Remove a specific suggestion from the
list, marking them as no longer suggested.
6. Update mutual friends count: Update the mutual friends count for a specific
user.
7. Exit: Exit the system.

Task 3: Browser Navigation System (Back, Forward, History)

Build a Browser Navigation System using a doubly linked list to simulate the functionality of
a browser’s navigation (back, forward, and history). Each node in the list represents a webpage
with attributes: Page URL, Page Title, Timestamp.
Requirements:

• Browser Operations:
1. Visit a new page: Add a new webpage to the current position in the list and
discard any forward history (nodes after the current one).
2. Back: Move one page back in the history (traverse to the previous node) and
display the page's details.
3. Forward: Move one page forward in the history (traverse to the next node) if
forward history exists.
4. View full history: Display all previously visited pages from the doubly linked list
(from the first page to the last).
5. Delete a specific page from history: Remove a specific page from the history
without breaking the list. If it’s the current page, move to the next one.
6. Clear history: Clear the entire browsing history.
7. History Search: Implement a search feature that lets users find and display a
webpage by its title or URL from any point in history.
8. Revisit Strategy: If a page is revisited (e.g., the same URL is visited multiple
times), move it to the current position and discard older instances, simulating
LRU (Least Recently Used) cache behavior.

Task 4: Task Management System with Undo/Redo and Task Dependencies

Design a Task Management System for project management where tasks are represented using
a doubly linked list. Each node represents a task with attributes: Task ID, Task Name, Task
Description, Task Status (Pending, Completed), and a Dependency List (list of tasks that must
be completed before this task can start).

Requirements:

• Task Management Operations:


1. Add a new task: Insert a new task into the list and update the dependency list if
there are tasks that must be completed first.
2. Mark task as completed: Mark a task as completed, ensuring all dependent tasks
have been finished first. Update the status of any tasks that depended on it.
3. Undo task completion: Implement an undo feature to revert the completion
status of the last completed task.
4. Redo task completion: Implement a redo feature to mark a previously undone
task as completed again.
5. View tasks: Display all tasks along with their dependencies and current status.
6. Delete a task: Remove a task from the list and handle its dependencies (either
mark the dependent tasks as blocked or allow reassignment of dependencies).

Task 5: Train Scheduling System with Real-Time Updates


Create a Train Scheduling System using a doubly linked list where each node represents a
train with attributes: Train Number, Departure Time, Arrival Time, Route (source to
destination), and Train Status (On Time, Delayed, Cancelled).

Requirements:

• Scheduling Operations:
1. Add a new train: Insert a train into the schedule based on its departure time,
keeping the list sorted by departure times.
2. Update train status: Update the status of a specific train (mark it as delayed, on
time, or canceled).
3. Remove a train: Delete a train from the schedule.
4. Find the next train to depart: Display the details of the next train that will
depart based on the current time (traverse forward in the list).
5. Display all trains for a specific route: Search and display all trains traveling on
a specific route, sorted by departure time.
6. Reverse traversal: Implement reverse traversal to view past departures (e.g., for
trains that have already left).
7. Exit: Exit the scheduling system.
8. Real-time updates: Implement a real-time clock that automatically updates the
train statuses (e.g., moving trains to the “Departed” or “Delayed” section based on
current time).
9. Reschedule trains: Allow rescheduling of trains (changing departure/arrival
times) and automatically reorder the list after the update.
10. Route optimization: Implement a route optimization algorithm that adjusts
train schedules to avoid conflicts (e.g., two trains departing from the same station
at the same time).

Task 6: CPU Round-Robin Scheduling Simulation

Simulate a CPU Round-Robin Scheduling System using a circular singly linked list. Each
node in the list represents a process with attributes like Process ID, Process Name, Execution
Time, and Remaining Burst Time.

Requirements:

• Scheduling Operations:
1. Add a new process: Insert a new process into the scheduling queue with its
respective execution time.
2. Simulate round-robin scheduling: Implement the round-robin scheduling
algorithm where each process is given a fixed time quantum to execute. If the
process completes within the time quantum, it is removed from the list. If not, the
remaining burst time is updated, and the process is moved to the end of the queue.
3. Display all processes: Traverse and display the details of all active processes,
including their remaining burst time.
4. Process completion: Once a process finishes execution (remaining burst time
becomes 0), remove it from the list.
5. Process preemption: Implement preemption such that if a higher-priority process
(with a lower process ID) is added during execution, it is inserted at the front of
the list and executed immediately after the current time quantum ends.
6. Idle CPU: If no processes are in the queue, display that the CPU is idle until a
new process is added.

Task 7: Real-Time Traffic Light Management System

Design a Real-Time Traffic Light Management System using a circular doubly linked list,
where each node represents a traffic intersection. Each intersection has attributes like
Intersection ID, Current Light Color (Red, Yellow, Green), Light Duration (in seconds for
each color), and Traffic Load (low, medium, high).

Requirements:

• Traffic Light Operations:


1. Add a new intersection: Insert a new intersection into the circular traffic system,
and initialize its light sequence.
2. Simulate traffic light changes: Implement a function that simulates the change
of traffic lights in sequence (Red -> Green -> Yellow -> Red) for each
intersection. The time duration for each light change is based on the traffic load
(e.g., high traffic load = longer green light).
3. Adjust traffic light duration: If the traffic load at an intersection change,
dynamically adjust the duration of each light phase for that intersection.
4. Display traffic light status: Traverse and display the current status (light color
and remaining time for the current phase) of each intersection in the circular list.
5. Priority intersection: Allow some intersections to have a priority mode (e.g.,
for emergency vehicles), where their green light duration is doubled, and they
move to the front of the cycle for quicker processing.
6. Traffic load balancing: If an intersection has been on red for too long due to
high traffic at other intersections, reduce the green time at other intersections
temporarily to allow the blocked intersection to move traffic.

(SIMILARITY IS STRONGLY PROHIBITED; YOUR ASSIGNMENTS WILL


BE CHECKED AGAINST SIMILARITY AND ACTION WILL BE TAKEN
ACCORDINGLY TO THE UNIVERSITY PLAGIARISM POLICY)

You might also like