Abstract Data Types Group 1
Abstract Data Types Group 1
TYPES
ABSTRACT DATA TYPES
Abstract Data Types (ADTs) are fundamental concepts in
computer science that define a data structure in terms of its
behavior (the operations that can be performed on it and the
properties of those operations), rather than its implementation.
This abstraction allows programmers to think about data structures
at a higher level without worrying about the underlying details.
ADTs are crucial for managing and organizing data efficiently.
STACKS
A stack is a linear data structure that follows LAST IN, FIRST
OUT (LIFO) principle. This means that the last element added to
the stack will be the first one to be removed. It's akin to a stack of
plates: you add (push) a new plate on top and remove (pop) the
topmost one first.
OPERATIONS :
- Push : Adds an element to the top of the stack.
- Pop : Removes the top element from the stack.
- Peek/Top : Retrieves the top element without removing it.
- isEmpty : Checks if the stack is empty.
ADVANTAGES OF QUEUE OVER OTHER
ABSTRACT DATA TYPES
First-In-First-Out (FIFO) Order:
Queues maintain the order of elements in a FIFO manner, which is
essential for scenarios where the order of processing matters (e.g.,
task scheduling, printing jobs).
Efficient Insertion and Deletion:
Insertion (enqueue) and deletion (dequeue) operations in a queue
are typically O(1) time complexity when implemented using linked
lists or circular arrays.
Fairness in Resource Allocation:
Queues ensure that the first element added is the first one to be
removed, making them ideal for fair resource allocation (e.g., CPU
scheduling, customer service systems).
Simplicity:
Queues are simple to implement and understand, making them a
good choice for problems that require sequential processing.
APPLICATIONS
- Function Call Management : In many programming
languages, function calls are managed using a call stack.
- Expression Evaluation : Stacks are used in evaluating
arithmetic expressions.
- Undo Mechanisms : Most software applications use
stacks for undo operations.
IMAGE REPRESENTATION OF STACK OPERATIONS
Arrays
Operations :
- Access : Access an element at a given index.
- Insertion : Insert an element at a specific position.
- Deletion : Remove an element from a specific position.
- Update : Modify an element at a specific index.
IMAGE REPRESENTATION OF AN ARRAY OPERATION
Queues
A queue is a linear data structure that follows the First In, First Out
(FIFO) principle. The first element added to the queue will be the first
one to be removed. It's similar to a line of people at a ticket counter.
OPERATIONS :
- Enqueue : Adds an element to the end of the queue.
- Dequeue : Removes the element from the front of the queue.
- Front : Retrieves the front element without removing it.
- isEmpty : Checks if the queue is empty.
APPLICATIONS :
- Scheduling : Managing tasks in an operating system.
- Buffering : Data buffering in streaming and networking.
- Breadth-First Search : Used in graph traversal algorithms
IMAGE REPRESENTATION OF BASIC QUEUE
OPERATIONS
ADVANTAGES OF QUEUES OVER OTHER ABSTRACT DATA
TYPES
BASIC OPERATIONS
Queues:
Task Scheduling: Operating systems use queues to manage processes in
a fair manner.
Printing Jobs: Printers use queues to manage multiple print requests.
Customer Service: Call centers use queues to handle incoming calls.
Stacks:
Undo/Redo Operations: Text editors and software use stacks to
implement undo/redo functionality.
Browser History: Browsers use stacks to manage the back and forward
navigation of web pages.
Linked Lists:
Used in dynamic memory allocation, implementing stacks, queues, and
graphs
Real-World Applications of
ADT .ctd
Trees:
Used in file systems, database indexing, and hierarchical data
representation.
Graphs:
Used in social networks, GPS navigation, and network routing.