Problem Statement : Back and Forward Navigation in Web Browser
Scenario:
You're building a simple web browser simulation. When users visit web pages, they
should be able to:
Go back to the previous page.
Go forward to the next page if they've previously gone back.
This is a classic application of two stacks:
One for the back history
One for the forward history
Requirements:
Use two stacks:
backStack for storing the history of visited pages.
forwardStack for storing pages after going back.
Support the following operations:
visit(URL) – Visit a new URL, clear forward stack, and push current page to back
stack.
back() – Pop from back stack, push current page to forward stack, and navigate to
the previous page.
forward() – Pop from forward stack, push current page to back stack, and navigate
to the next page.
Print the current page after each operation.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-
Problem Statement: Undo Operation in a Text Editor
Scenario:
You are developing a simple text editor. One of the essential features is the Undo
operation, where the user can
undo their last action (like typing or deleting a character). This can be
efficiently implemented using a stack, as
it follows Last-In-First-Out (LIFO) behavior.
Requirements:
Implement a stack in C to store the user's operations (like insert and delete).
Each operation should be pushed onto the stack.
When the user chooses to undo, the last operation should be popped and reversed.
Support the following operations:
Insert a character
Delete the last character
Undo the last operation
Display the current content after each operation.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-
Problem Statement: Patient Record Management System in a Clinic
Scenario:
You are developing a patient queue management system for a small clinic. The doctor
wants to maintain a dynamic list of patients,
where each patient is served in the order they arrive, but patients can also be
removed or added dynamically based on emergency
or cancellations.
A linked list is ideal here because:
Patients may arrive or cancel at any time.
Memory is dynamically allocated.
Insertion/deletion operations are more efficient compared to arrays.
Requirements:
Use a singly linked list to store patient records.
Each patient node should include:
Patient ID
Name
Age
Reason for visit
Support the following operations:
AddPatientAtEnd() – Normal patient arrives and is added at the end.
AddEmergencyPatientAtStart() – Emergency patient is added at the front.
ServePatient() – Serve the first patient in the queue (delete from front).
CancelPatient(ID) – Remove a patient by ID.
DisplayPatients() – Display the current queue of patients.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-
Problem Statement: Music Playlist Manager
Scenario:
You are designing a music playlist manager for a media player app. Users can add
songs, delete songs, and navigate through
the playlist. The playlist should allow:
Dynamic addition/removal of songs
Moving to the next or previous song
Viewing the current song
A doubly linked list is ideal here, as it allows bi-directional traversal (forward
and backward through the playlist).
Requirements:
Use a doubly linked list where each node represents a song.
Each song node should store:
Song ID
Title
Artist
Duration
Support the following operations:
AddSong() – Add a new song to the end of the playlist.
DeleteSong(songID) – Remove a song by its ID.
NextSong() – Move to the next song.
PreviousSong() – Move to the previous song.
DisplayCurrentSong() – Show details of the current song.
DisplayPlaylist() – Show all songs in order.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-
Problem Statement: Student Enrollment System
Scenario:
You are tasked with designing a student enrollment system for a college department.
Students enroll and drop courses dynamically.
The system needs to maintain a list of enrolled students with their details,
allowing adding, removing, and searching students.
A singly linked list is a good fit for managing this dynamic collection.
Requirements:
Implement a singly linked list to store student records.
Each student node should include:
Student ID (unique)
Name
Course enrolled
Support the following operations:
AddStudent() – Add a student to the end of the list.
RemoveStudentByID() – Remove a student by their ID.
SearchStudentByID() – Search and display a student’s details by ID.
DisplayAllStudents() – Display the entire list of students.
CountStudents() – Return the total number of students enrolled.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-
Problem Statement: Restaurant Order Management System
Scenario:
You are designing a system to manage customer orders in a restaurant. Orders are
placed in the sequence they come in
and served in the same order (FIFO). The restaurant wants to keep track of orders
waiting to be prepared and served.
Using a queue will help manage this process efficiently.
Requirements:
Implement a queue in C (array-based circular queue or linked list).
Each order should include:
Order ID
Customer Name
Order Details (string)
Support the following operations:
PlaceOrder() – Add a new order to the queue.
ServeOrder() – Remove the order at the front when served.
DisplayOrders() – Display all pending orders.
PeekNextOrder() – Show details of the next order to be served.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-
Problem Statement: Emergency Room Patient Queue
Scenario:
In a hospital emergency room, patients arrive and wait to be treated. Normally,
patients are served in the order they arrive (FIFO).
However, if a patient has a critical condition (emergency), they must be treated
immediately, before others in the queue.
Implement a system using two queues or a priority queue simulation to manage:
Normal patients (served in arrival order)
Emergency patients (served before normal patients)
Requirements:
Use two queues:
One for emergency patients
One for normal patients
Each patient record includes:
Patient ID
Name
Condition severity (normal or emergency)
Support the following operations:
AddPatient() – Add a patient to the appropriate queue.
ServePatient() – Serve patients giving priority to emergency queue first.
DisplayQueues() – Display patients waiting in both queues.
After serving all emergency patients, normal patients are served.