Data Structures Explained

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Exploring

Data Structures
and Their Types

@Kiran Kanwar Rathore


Data structures are ways of
organizing and storing data in a
computer's memory or storage, so
that it can be accessed and
manipulated efficiently.

A data structure provides a way of


representing data in a structured
manner, so that it can be easily
processed and analyzed.

@Kiran Kanwar Rathore


Types of Data
Structures
There are many types of data structures,
such as :

1. Linear data structures:


Arrays
Linked lists
Stacks
Queues
2. Non-linear data structures:
Trees
Graphs

3. Hash-based data structures:


Hash tables

4. Heap-based data structures:


Heaps
@Kiran Kanwar Rathore
5. Trie-based data structures:
Tries

6. Set-based data structures:


Sets

7. Map-based data structures:


Maps

8. String-based data structures:


Strings
Array :
An array is a data structure that stores a
fixed-size, contiguous block of elements of
the same data type.

It provides fast access to any element


within the array, but inserting or deleting
elements can be slow as it may require
shifting all elements.

Arrays are commonly used in algorithms


and data processing.

@Kiran Kanwar Rathore


Linked List:
A linked list is a linear data structure that
consists of nodes linked together by
pointers.

Each node contains a data element and a


pointer to the next node in the list. Linked
lists provide efficient insertion and
deletion of elements but may have slower
access times than arrays.

They are commonly used in dynamic data


structures and graph algorithms.

@Kiran Kanwar Rathore


Stack:
A stack is a linear data structure that
follows the Last-In-First-Out (LIFO)
principle. It allows elements to be added
and removed only from the top of the
stack.

Stacks are useful for implementing


algorithms like depth-first search and
function calls in programming
languages.

@Kiran Kanwar Rathore


Queue:
A queue is a linear data structure that
follows the First-In-First-Out (FIFO)
principle.

It allows elements to be added to the back


of the queue and removed from the front.

Queues are useful for implementing


algorithms like breadth-first search and
simulating real-world scenarios like waiting
in line.
Tree:
A tree is a hierarchical data structure
that consists of nodes connected by
edges.

It has a root node and every other


node has a parent node and zero or
more child nodes.

Trees are useful for organizing data in


a hierarchical structure and
implementing search algorithms like
binary search.

@Kiran Kanwar Rathore


Graph:
A graph is a non-linear data structure
that consists of vertices or nodes
connected by edges.

It can be used to represent complex


relationships between data points and is
commonly used in algorithm design and
optimization problems.

Graphs can be directed or undirected,


weighted or unweighted, and can have
cycles or not.

@Kiran Kanwar Rathore


Hash Table:
A hash table is a data structure that
uses a hash function to map keys to
values, allowing for efficient retrieval
and insertion of data.

Hash tables have constant time


complexity for searching, insertion,
and deletion, making them ideal for
large datasets and real-time
applications.

@Kiran Kanwar Rathore


Heap:
A heap is a binary tree-based data
structure that satisfies the heap property,
which ensures that the value of each
parent node is greater than or equal to its
children.
@Kiran Kanwar Rathore

It provides efficient access to the


maximum or minimum element in the data
set and is used in sorting algorithms like
heapsort and implementing priority
queues.

@Kiran Kanwar Rathore


Tries:
A trie is a tree-like data structure that
stores strings or sequences of elements.

Each node in the tree represents a


prefix of the string and can store
additional information, such as a
boolean value to indicate if the string is
a valid word.

Tries are commonly used in algorithms


for text processing and string matching.

@Kiran Kanwar Rathore


Sets:
A set is a collection of unique
elements, where the order of the
elements does not matter.

Sets are useful for removing


duplicates from a list, checking if an
element is present in a collection, or
performing operations like union,
intersection, and difference on
multiple sets.

@Kiran Kanwar Rathore


Maps:
A map, also known as a dictionary or
associative array, is a collection of
key-value pairs where each key is
associated with a value.

Maps are useful for storing and


retrieving data efficiently based on a
key, such as the name and age of a
person or the ID and price of a
product.

@Kiran Kanwar Rathore


Strings:
A string is a sequence of characters,
such as letters, numbers, or symbols,
that can be manipulated and processed
by computers.

Strings are often used for text


processing, such as searching for a
pattern within a string, or performing
operations like concatenation and
substring extraction.

Strings are a fundamental data type in


many programming languages.
@Kiran Kanwar Rathore
Did you find this post
helpful
Follow us on

@Kiran Kanwar Rathore

@Maheshpal Singh

You might also like