DSA - Mini - Project Faheem
DSA - Mini - Project Faheem
(CS3291)
MINI PROJECT
ON
QUEUE
Mohamed Faheem S
IT 2nd year
210622205041
QUEUE
Aim:
To implement a simple task management system using a queue data structure.
Explanation:
- The `Queue` class is implemented with basic queue operations (`enqueue`,
`dequeue`, `is_empty`, and `size`).
- The `main` function initializes a task queue and provides a simple menu for
users to add tasks, process tasks, view tasks, or exit the system.
- The program continues running until the user chooses to exit.
Source code:
class Queue:
def __init__(self):
self.items = []
def is_empty(self):
return len(self.items) == 0
def enqueue(self, item):
self.items.append(item)
def dequeue(self):
if not self.is_empty():
return self.items.pop(0)
else:
print("Queue is empty.")
return None
def size(self):
return len(self.items)
def main():
task_queue = Queue()
while True:
print("\nTask Management System:")
print("1. Add Task")
print("2. Process Task")
print("3. View Tasks")
print("4. Exit")
if choice == "1":
task = input("Enter the task: ")
task_queue.enqueue(task)
print(f"Task '{task}' added to the queue.")
else:
print("Invalid choice. Please enter a number between 1 and 4.")
if __name__ == "__main__":
main()
OUTPUT: -
CONCLUSION
In conclusion, the implemented Task
Management System using a queue provides a straightforward
example of how queues, a fundamental data structure, can be utilized
in a real-world scenario. The code allows users to add tasks to a
queue, process tasks in a first-come, first-served manner, and view the
current tasks in the queue. The system demonstrates the simplicity
and efficiency of using a queue to manage tasks in a sequential order.
********