0% found this document useful (0 votes)
20 views16 pages

COM212

Uploaded by

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

COM212

Uploaded by

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

DATA STRUCTURES

Data structures are a systematic way of organizing and


managing data to enable efficient access and
modification. Presentation by:

• Sengonzi Jonathan 195-


777
• Kyokwijuka Ritah 198-
551
• Tendo Isaac Baguma 193-
448
1
THE PRESENTATION COVERS THE
APPLICATIONS OF THE FOLLOWING
DATA STRUCTURES.

• Array Data Structure


• Linked List Data
Structure
• Stack Data Structure
• Queue Data Structure
• Tree Data Structure
• Heap Data Structure
• Graph Data Structure

2
Array Data An array is a data structure that stores a collection of
Structure elements in sequential memory locations one after the other.

Characteristics of an Array.
Each element in an array can be efficiently accessed using its index, which
represents its position within the array.
This direct access property makes arrays highly efficient for several
operations, such as indexing, iterating, and modifying elements.
Array element 15 can be accessed via its Application Areas of Arrays.
index
2
Applications of Arrays.

• Used in implementing mathematical data structures such as matrices and tensors. These structures are
pivotal in fields like linear algebra, numerical analysis, and machine learning. For instance, matrices, which are
two-dimensional arrays, enable operations such as matrix multiplication, determinant calculation, and matrix
inversion, fundamental in solving systems of linear equations and transformations in graphics
Array element 13 can be
accessed
• Used using
in Gameits index
development.
2 Arrays are used to represent 2D or 3D game boards, such as in chess, tic-tac-toe, or
grid-based games like Minesweeper or Tetris.
Application Areas of
Arrays.
• Used in Computer Graphics. In computer graphics, arrays are employed to represent images, where each element in the
array corresponds to a pixel’s color value. For example, a grayscale image can be stored in a two-dimensional array where
each element holds an intensity value. For colored images, three-dimensional arrays are used to store the red, green, and
blue (RGB) components of each pixel

• Used in Text processing and manipulation. Strings, which are essentially sequences of characters, can be viewed as
arrays of characters. Various operations such as searching, sorting, and pattern matching (e.g., the Knuth-Morris-Pratt
algorithm) utilize arrays for efficient implementation.

• Used in Sorting algorithms. Sorting algorithms including quicksort and merge sort, utilize arrays as the underlying data
structure for their operations. The efficiency of these algorithms, driven by the array’s random-access capability.

4
A linked list is a linear data structure consisting of a series of
Linked List Data
connected nodes, where each node contains:
Structure 1. Data: The value or information stored in the node.
2. Pointer (or Reference): A reference (or link) to the next
node in the sequence.

Applications of Linked Lists.

Linked lists back and forth nature provides versatile and powerful structures adaptable to a myriad of applications:

• Undo Functionality in Applications:


Applications, such as text editors, implement an undo feature using linked lists. Each change is stored in a node,
forming a list that represents the sequence of actions. Reversing the change involves traversing this list and rolling
back the actions.

• Music Playlists: Enables sequential navigation with "next" and "previous" functionality.

5
Applications of Linked
lists.
• Used in File Systems:
Linked lists manage directories and file storage, allowing files to be stored in non-contiguous
memory locations. Each file block points to the next, enabling flexible storage management.

• Back and Forward Navigation in Browsers:


Browsers use doubly linked lists to manage visited web pages, enabling "back" and "forward"
functionality.

• Dynamic Comment Systems:


In websites like forums, blogs, or social media platforms, linked lists handle threaded
comments where each comment is linked to its parent comment.

6
Stack Data A stack is a linear data structure that adheres to the Last In, First Out
Structure (LIFO) principle. In a stack, the element added last is the one to be removed
first. This characteristic makes stacks useful when data needs to be stored
and retrieved in reverse order from which it was added.

Fundamental Stack Operations:


Push: Adds an element to the top of the stack.
Pop: Removes the element from the top of the stack.
Since 3 was inserted last, it gets Peek: Returns the top element of the stack without removing it.
retrieved first, Hence the LIFO principle
of a stack.
Applications of Stacks.

• Undo Mechanisms: Many applications, such as text editors, implement undo mechanisms by maintaining
actions in a stack. When an operation is performed, it is pushed onto the undo stack. To undo an operation, it is
popped from the stack, and an opposite action is executed (which might be pushed onto a redo stack).

• Depth-First Search (DFS): In graph traversal algorithms, such as Depth-First Search, stacks are
utilized to explore nodes in a depth-ward motion. Each time a new node is visited, it is pushed onto the
stack; backtracking occurs when a node has no unvisited adjacent nodes, achieved by popping the
stack.
Applications of Stacks.
• Recursive Function Calls:
Programming languages use a call stack to manage function calls. When a function is called,
its data (like local variables) is pushed onto the stack, and when the function finishes, the data
is popped off.

• Compilers and Interpreters:


Stacks are used to parse and validate the syntax of programming languages, ensuring correct
grammar and structure.

• Back and Forward Navigation:


Web browsers use stacks to implement "Back" and "Forward" navigation:
• Back Stack: Tracks previously visited pages.
• Forward Stack: Tracks pages navigated after pressing "Back.“

• Memory Management
Stacks are utilized for managing memory during program execution:
• Allocation of Function Calls: Allocating and deallocating memory for function
parameters, return addresses, and local variables.
8
QUEUE Data A queue is a linear data structure that follows a specific order for element
operations, known as First-In First-Out (FIFO). In a queue, the first element
Structure
added to the structure will be the first one to be removed.

Fundamental Queue Operations:


Enqueue: Adding an element to the end of the queue.
Dequeue: Removing an element from the front of the queue.
Front: Retrieves, but does not remove, the front element of the queue.
Since 2 was inserted first, it gets Rear: Retrieves, but does not remove, the last element of the queue
retrieved first, Hence the FIFO principle .
of a queue.
Applications of Queue.

• Task Scheduling: Queues are extensively used in operating systems for task scheduling. In a multitasking
environment, where numerous processes compete for CPU time, a queue can manage these processes efficiently.

• Print Spooling: In a networked environment with multiple print requests, queues manage print job spooling.
Each print job is placed in a queue and processed sequentially, ensuring that print commands are executed in the
order they were received.
Applications of Queues.
• Breadth-First Search (BFS) in Graphs: Queues facilitate the BFS algorithm in graph traversal, ensuring
exploration starts from the given node and moves level by level.

• Customer Service Systems: Customer service departments utilize queues to manage incoming customer
requests, be it in a call center or a service desk. Each customer is attended to in the order they arrived, which
is crucial for fairness and efficiency.

• Traffic Management: Queues are utilized in traffic management systems, especially at traffic signals. Vehicles
queue up at red lights and are allowed to pass sequentially when the light turns green, ensuring orderly traffic flow.

10
Tree Data Structure A tree is a hierarchical data structure that simulates a hierarchical tree
structure with a root value and subtrees of children, represented as a set of
linked nodes.

Concepts Associated with Trees:


Nodes: A node is an individual element of a tree holding data.
Edges: An edge is the connection between two nodes.
Root: The node at the top of the tree with no parent is called the root

Applications of Trees.

• Network Routing: Trees are essential in network routing algorithms. Spanning trees, for example, are
utilized in network topology management to prevent loops.

• File Systems: Modern file systems often leverage tree structures for efficient file storage and retrieval.
Examples include the ext4 file system in Linux,
Applications of Trees.
• Database indexing: Binary search trees are used for searching and organizing data efficiently.
B-trees are commonly used in databases to enable efficient range queries and index management.

• Data Compression: Trees, specifically Huffman trees, are instrumental in data compression algorithms. Huffman
encoding uses a binary tree to assign variable-length codes to input characters, based on their frequencies. Characters
that occur more frequently are given shorter codes, which helps in reducing the overall size of the data.

• Expression Parsing in Calculators: Evaluations of mathematical expressions in calculators and other


arithmetic processing tools often make use of expression trees. Each node in the tree represents an operator, and the
children nodes represent the operands.

12
Heap Data Heaps are a specialized tree-based data structure that satisfies the heap
Structure property.
A heap can be of two types:
A min-heap: for any given node i, the value of i is less than or equal to
the values of its children.
A max-heap: the value of i is greater than or equal to the values of its
children.

Applications of Heaps.
• Priority Queues: Heaps are the most efficient way to implement priority queues, where
elements with the highest or lowest priority are processed first.
• Max-Heap: Supports extracting the highest priority element efficiently.
• Min-Heap: Supports extracting the lowest priority element efficiently.

• Heap Sort: Heaps are used in the heap sort algorithm, which organizes data in
ascending or descending order efficiently.
Applications of Heaps.
• Resource Allocation and Load Balancing: Heaps help manage resources efficiently in
systems requiring dynamic allocation. Applications:
• Distributing tasks among multiple processors or servers.
• Managing virtual memory allocation in operating systems.

• Used in compression algorithms: A min-heap is used to create a Huffman tree, which generates
optimal prefix codes for data compression.

• Social media and e-commerce platforms use heaps to rank search results or posts by relevance
(priority ranking).

14
Graph Data A graph G is an abstract data structure that consists of a set of vertices V (or
Structure nodes) and a set of edges E connecting pairs of vertices.

The two primary components of a graph are:


Vertices (or Nodes): These are the fundamental units in the graph.
Edges: These represent the connections between vertices. Edges can be
directed or undirected, weighted or unweighted.

Applications of Graphs.

• Social Networks: In social networks, graphs are employed to represent users as vertices, with edges
denoting relationships between them.

• Biological Networks: Graphs play an instrumental role in bioinformatics, particularly in modeling


biological networks. In a protein-protein interaction (PPI) network, vertices represent proteins, and edges indicate
interactions
Applications of Graphs.
• Transportation and Navigation: Graphs are fundamental in representing transportation and navigation
systems. For instance, vertices can represent intersections or stations in road and rail networks, while edges denote the
connecting roads or tracks.

Telecommunications Networks: Telecommunications networks, including the internet, can be modeled as
graphs where vertices represent routers, switches, or other types of infrastructure, and edges symbolize the
communication links.

• Utilities and Resource Management: Utility networks, such as electrical grids and water distribution
systems, capitalize on graph theory. Here, vertices represent substations or nodes, while edges correspond to
transmission lines or pipes.

16

You might also like