DS Miniproject
DS Miniproject
Submitted
To
Dr. J VENKATA KRISHNA
Associate Professor, Dept of CSE
2024-2025
SRINIVAS UNIVERSITY INSTITUTE
OF ENGINEERING AND TECHNOLOGY MUKKA,
MANGALURU – 574146
CERTIFICATE
This is to certify that the miniproject “DATA STRUCTURES-1” is a bonafide work carried out
by GOWTHAMI, GRISHA, HRYDYA MOHANAN, JAIBUNNISA SHAIKH. USN Number:
01SU23CS068, 01SU23CS069, 01SU23CS078, 01SU23CS079. In the partial fulfillment for the
award of Bachelor of Technology in Computer science of the Srinivas University, Institute of
Engineering & Technology during the year 2023-2024.It is certified that all
corrections/suggestions indicated for internal assessment have been incorporated in the report
deposited in the department library. The miniproject report has been approved as it satisfies the
academic requirements in respect of miniproject work prescribed for the said degree .
___________________
Dr J Venkata Krishana
(Miniproject Guide)
SRINIVAS UNIVERSITY INSTITUTE OF
ENGINEERING & TECHNOLOGY MUKKA,
MANGALURU – 574146
DECLARATION
We, GOWTHAMI, GRISHA, HRIDYA MOHANAN, JAIBUNNISA SHAIKH the student of
third semester, B.Tech in Computer science University, Mukka, hereby declare that the mini
project titled ”Employee Management System using Python“ has been successfully completed by
us in partial ulfillment of the requirements in Bachelor of Technology in Computer science of
Srinivas University, Institute of Engineering and Technology.
Date: 21/10/2024
Place: Mukka
ABSTRACT
Data structures are a fundamental concept in computer science, and Python, being a versatile and
powerful programming language, offers a wide array of built-in data structures such as lists,
dictionaries, tuples, and sets, along with the flexibility to implement custom data structures like
linked lists, stacks, queues, and trees. This abstract delves into the importance of data structures
in Python, exploring their efficiency in managing and organizing data, enabling optimized
searching, sorting, and manipulation operations. We highlight the significance of choosing the
right data structure to improve time complexity and storage requirements for algorithms,
emphasizing Python’s user-friendly syntax and dynamic nature that makes working with data
structures both efficient and intuitive. Furthermore, Python’s standard library, particularly
modules like collections and heapq, extends the capabilities of basic data structures, offering
specialized structures such as named tuples, deques, and priority queues, making Python a robust
tool for solving complex computational problems. This abstract provides an overview of data
structures in Python and their critical role in developing efficient and scalable applications.
ACKNOWLEDGEMENT
It is our pleasure to acknowledge for all those who have provided guidance, inspiration and
encouragement for the successful completion of our mini project. We take this opportunity to
express our profound gratitude to our respected guide Dr J Venkata Krishna , Associate
Professor, Dept of CSE for her ever-inspiring guidance, constant encouragement and support.
We sincerely thank, Dr J Venkata Krishna, Associate Professor, Computer science &
Engineering, for being an inspiration and support throughout this miniproject. We are extremely
grateful to our respected Dean, Dr. N Ramakrishna Hegde for providing the facilities to carry
out the miniproject presentation. We would like to thank our Management, A. Shama Rao
Foundation, Mangalore, for providing the means of support. We also extend our thanks to all
teaching, non-teaching staff and management staff who have been helpful and cooperative
towards the completion of the miniproject.
TABLE OF CONTENTS
1. INTRODUCTION
2.
CHARACTERISTICS
3.
COMMON OPERATIONS
4. COMMON FACTORS
5. APPLICATIONS
6. CODE
7. OUTPUT
8. CONCLUSION
INTRODUCTION
1. Array:
An array is a fundamental data structure that stores elements in contiguous memory locations. It
allows for the storage of multiple items of the same type together. The primary operations that
can be performed on arrays include accessing elements by index, inserting, deleting, and
updating elements. Arrays are widely used due to their simplicity and efficiency in accessing
elements, as any element can be retrieved using its index in constant time.
2. Circular Queue:
A circular queue is an advanced form of a queue where the last position is connected back to the
first position to make a circle. Unlike a simple linear queue, when a circular queue reaches its
end, it can wrap around to the front and reuse empty spaces at the beginning (if any). This helps
in better space utilization. Circular queues are commonly used in scenarios where memory is
limited, such as buffering in streaming data or managing processes in operating systems.
3. Stack:
A stack is a linear data structure that follows the Last-In-First-Out (LIFO) principle, meaning the
last element added is the first one to be removed. It has two primary operations: push, which
adds an element to the top, and pop, which removes the top element. Stacks are often used in
scenarios like undo functionality in text editors, expression evaluation, and managing function
calls in programming (call stacks).
These data structures serve as building blocks for more complex algorithms and are essential for
efficient problem-solving in computing.
CHARACTERISTICS
1. Array:
Characteristics:
Fixed Size: The size of an array is usually defined at the time of its creation and cannot
be changed.
Homogeneous: Elements in an array are of the same data type (though Python lists can
contain mixed types).
Random Access: Elements can be accessed directly using their index.
Static vs. Dynamic: In some languages (like C or Java), arrays are static, meaning the
size is fixed at the time of declaration. In Python, lists can grow or shrink dynamically.
Contiguous Memory: Elements in an array are stored in contiguous (adjacent) memory
locations, making access to any element very fast.
Index-based Access: Direct access to elements using index, i.e., O(1) access time.
2. Circular Queue
Characteristics:
3. Stack:
Characteristics:
COMMON OPERATIONS
1. Array:
2. Circular Queue:
3. Stack:
Push/Pop: Both operations take O(1) time. Pushing adds an element to the top of the
stack, while popping removes the top element.
isEmpty: Check if the stack is empty.
Peek: Retrieves the top element without removing it (also an O(1) operation).
Reversing/Backtracking: Stacks are often used for reversing data, such as in string
reversal or backtracking algorithms.
Common Factors
1.Linear Data Structures:
Both arrays, circular queues, and stacks are linear data structures. This means their
elements are stored in a linear order (sequentially).
2.Memory Utilization:
Array: Uses contiguous memory locations, which can lead to memory overflow if not
enough space is allocated.
Circular Queue: Efficient memory usage since it reuses empty spaces left by dequeued
elements.
Stack: Memory is only used for the elements in the stack. When elements are removed
(popped), memory is freed up.
3.Access Patterns:
Array: Typically has a fixed size, though Python lists are dynamic.
Circular Queue: Fixed size.
Stack: Can be fixed (array-based) or dynamic (list/linked list-based).
5.Complexity:
Insertion/Deletion:
Arrays: Insertion and deletion can be costly, with a time complexity of O(n) in the
worst case (inserting or deleting in the middle or beginning).
Circular Queue and Stack: Insertions and deletions are constant time O(1).
6.Overflow/Underflow Conditions:
Array: No overflow condition unless it's a statically sized array (like in C/C++).
Circular Queue: Has both overflow (when full) and underflow (when empty) conditions.
Stack: Can overflow (when full in fixed-size stacks) or underflow (when trying to pop
from an empty stack).
Each data structure has specific applications where it excels due to its characteristics. Below, we
discuss practical use cases for arrays, circular queues, and stacks in real-world applications.
1.Array:
Arrays are one of the most fundamental data structures and are used in a wide range of
applications due to their simplicity and fast access times. Here are some key applications:
Applications of Arrays:
Arrays are often used to store a collection of elements like lookup tables, where
you need fast access to elements. For example, an array of prices for different
products in an e-commerce application.
2. Mathematical Computations:
o Arrays are used to store matrices and vectors in mathematical computations and
scientific calculations. For instance, in machine learning and scientific
computing, NumPy arrays are widely used.
3. Image Processing:
o Digital images are stored as 2D arrays (matrices) of pixels. Each pixel in the
array represents a color value (RGB, grayscale, etc.).
4. Database Systems:
o Arrays are used to store records in a contiguous block of memory, allowing for
fast retrieval of rows from a table.
5. Hash Tables:
o Arrays can serve as the underlying structure in hash tables, where each index
corresponds to a bucket.
6. Multidimensional Arrays:
Storing Student Grades: An array can store the grades of students, allowing quick
access to a student’s grade using their index (position).
2. Circular Queue:
Circular queues have unique advantages over regular queues, especially when memory
utilization is crucial. Their wrap-around behavior allows efficient use of available space, making
them ideal in specific applications.
2. Buffer Management:
o Circular queues are widely used in buffering scenarios, such as handling
streaming data (audio/video streaming). The queue maintains a circular buffer to
ensure continuous data flow without overflow or underflow.
3. Network Packet Scheduling:
o In network routers and switches, circular queues are used to manage packets. Data
packets are enqueued at the rear and dequeued from the front in a circular manner.
4. I/O Buffers:
o Circular buffers are often used in hardware I/O operations where data is read and
written simultaneously (e.g., in printers, sound cards). It helps maintain a smooth
flow of data between the producer and consumer.
5. Real-Time Systems:
o In embedded systems and real-time operating systems, circular queues manage
tasks, ensuring smooth task switching and resource management without using
excessive memory.
Keyboard Buffer: When typing, the characters you input are stored temporarily in a
circular queue before being processed by the CPU.
3. Stack:
Stacks are used extensively in computer science due to their LIFO (Last In First Out) property.
They are essential for various algorithms and system-level operations.
Applications of Stacks:
Reversing a String: You can use a stack to reverse a string by pushing each character
onto the stack and then popping them off in reverse order.
Summary of Applications:
Data Applications
Structure
1.PROGRAM ON ARRAY:
MAX = 10
def cqinsert(queue, rear, count):
if count == MAX:
print("Queue is Full")
else:
ele = input("Enter a Character: ")
rear = (rear + 1) % MAX
queue[rear] = ele
count += 1
return rear, count
def cqdelete(queue, front, count):
if count == 0:
print("Queue is Empty")
else:
print(f"Deleted Character is {queue[front]}")
front = (front + 1) % MAX
count -= 1
return front, count
def display(queue, front, count):
if count == 0:
print("Queue is Empty")
else:
print("The Characters are:")
for i in range(count):
print(queue[front], end='\t')
front = (front + 1) % MAX
print()
def menu():
queue = [''] * MAX
front = 0
rear = -1
count = 0
while True:
print("\nMenu")
print("1. Insert")
print("2. Delete")
print("3. Display")
print("4. Exit")
ch = int(input("Enter your choice: "))
if ch == 1:
rear, count = cqinsert(queue, rear, count)
elif ch == 2:
front, count = cqdelete(queue, front, count)
elif ch == 3:
display(queue, front, count)
elif ch == 4:
print("Exiting...")
break
else:
print("Invalid choice, please try again.")
if __name__ == "__main__":
menu()
OUTPUT:
3.PROGRAM ON STACK:
MAX = 20
def stack_full(top):
def stack_empty(top):
return top == -1
if stack_full(top):
print("Stack Full")
return top
else:
stack.append(ele)
return top + 1
if stack_empty(top):
print("Stack Empty")
else:
ele = stack.pop()
if stack_empty(top):
print("Stack Empty")
else:
stack = []
top = -1
while True:
print("\nMenu")
print("1. Push")
print("2. Pop")
print("4. Display")
print("5. Exit")
if ch == 1:
if stack_full(top):
print("Stack Full")
else:
elif ch == 2:
if stack_empty(top):
print("Stack Empty")
else:
elif ch == 3:
if stack_empty(top):
print("Stack Empty")
elif stack_full(top):
print("Stack Full")
else:
elif ch == 4:
display(stack, top)
elif ch == 5:
print("Exiting...")
break
else:
if _name_ == "_main_":
menu()
OUTPUT:
Conclusion
Arrays, circular queues, and stacks are essential data structures with distinct characteristics that
make them suitable for specific tasks in computer science and programming.
Arrays provide fast random access to elements and are ideal for storing collections of
data where quick retrieval is important. They are widely used in situations such as data
storage, image processing, and lookup tables, but their fixed size and inefficiency in
insertions and deletions can be limiting.
Circular Queues are optimal for scenarios that require efficient space utilization and
continuous data flow, like buffering in streaming systems, task scheduling, and real-time
processing. Their ability to reuse space through wrap-around behavior makes them more
efficient than linear queues in many applications.
Stacks are perfect for managing tasks that follow a LIFO (Last In First Out) order. They
are essential in areas like recursion, function call management, backtracking algorithms,
and undo/redo functionalities in software applications.
Each data structure has its advantages, and choosing the right one depends on the specific needs
of the problem. Mastering these data structures allows developers to write more efficient and
optimized code, improving both performance and resource management in various computing
applications.