This document provides an introduction to data structures. It defines data and structures, and explains that data structures provide organized ways to store and retrieve data. The document then covers several common linear data structures like arrays, stacks, queues, and linked lists. It describes each structure's properties and common operations. The document also discusses non-linear data structures like trees and graphs, their representations and operations. Finally, it provides guidance on selecting the appropriate data structure based on a problem's resource constraints and required operations.
2. Basic Terminologies
zaid shabbir
Data Structure
Data: are simply a value are set of values of different
type which is called data types like string, integer, char
etc.
Structure: Way of organizing information, so that it is
easier to use
In simple words :
Its a way organizing data in such a way so that data can be
easier to use.
3. What is Data structure?
• It is a format for storing data in an organized
manner.
• A logical way of storing data and it also define
mechanism of retrieve data
• Abstract way to organize information.
4. Why do we need Data structures?
• Human requirement with computer are going to
complex day by day. To solve the complex
requirements in efficient way we need this study.
• It is a method/ technique for storing and organizing
the information in a computing machine.
• Since it is all organized and well maintained,
storage is properly taken care of and the data being
searched for can be retrieved very easily and f
5. • Generally classified as:
1. Primitive:- Primitive data types are
predefined types of data, which are supported
by the programming language. For example,
integer, character, and string are all primitive
data types.
2. Non Primitive :-Not defined by the
programming language, but are instead created
by the programmer.
7. Operation on Linear/Non-Linear
Data Structure
●
●
●
●
●
Add an element
Delete an element
Traverse / Display
Sort the list of elements
Search for a data element
8. Types of Data Structure
Array:
• An array is defined as it is a collection of items
stored at contiguous memory locations.
• Arrays are the set of homogeneous data
elements stored in RAM, therefore, it can hold
only one type of data.
10. Types of Data Structure ...
Stack: A stack is a data structure in
which items can be inserted only from
one end and get items back from the
same end.
There , the last item inserted into
stack, is the the first item to be taken
out from the stack.
In short its also called Last in First
out [LIFO].
zaid shabbir
11. • Operations performed here:
Push :- add a element in stack
Pop :- remove an element in stack
• ADVANTAGES
1. Easy to started
2. Less Hardware
Requirement
3. Cross- Platform
• DIS ADVANTAGES
1. not flexible
2. Lack of scailability
12. Types of Data Structure ...
QUEUE: A queue is two ended
data structure in which items can
be inserted from one end and
taken out from other end.
Therefore , the first item inserted
into queue is the first item to be
taken out from the queue.
This property is called First in
First out [FIFO].
zaid shabbir
13. • Operations performed here:
Enqueue:- add a element in queue
Dequeue :- remove an element in queue
• Pros:
1. Being able to handle
multiple data types
2. Flexibility and fast.
• Cons:
1. A new element can only
be inserted when all of the
elements are deleted from
the queue.
14. Types of Data Structure ...
Linked List: In linked list space to store items is
created as is needed and destroyed when space no
longer required to store items.
It is a linear collection of data elements. It has two
parts:
1.Info :- gives information
2. other’s link part.- gives other node’s address
Hence linked list is a dynamic data structure.
15. • Operations performed in Linked list
Traversing
Searching
Insertion
Deletion
• Pros:
1. You can also decrease and increase
the linked list at run-time.
2. Memory is well utilized in the linked list. Because in it, we do not
have to allocate memory in advance.
3. Its access time is very fast, and it can be accessed at a certain
time without memory overhead.
• Cons
1. The linked list requires more memory to store the elements than
an array, because each node of the linked list points a pointer,
due to which it requires more memory.
2. It is very difficult to traverse the nodes in a linked list.
16. Types of Data Structure ...
• Tree: Non-linear data structure which is
mainly used to represent data containing a
hierarchical relationship between elements
• The data structure which
reflects this relationship is
called tree.
17. • Operations
1. Traversing
2. Searching
3. Insertion a
4. Deletion
• Pros:
1. It provides an efficient insertion and searching operations.
2. Trees are flexible.
• Cons:
1. A small change in the data can cause a large change in the
structure of the decision tree causing instability
2. It is relatively expensive as the complexity and time has
taken are more.
18. Types of Data Structure ...
Graph: Data sometimes contain a relationship
between pairs of elements which is not
necessarily hierarchical in nature.
For example, an airline flies only between cities
connected by lines.
It is a set of items connected by edges. Each
item is called a vertex or node.
19. • Trees are just like a special kinds of
graphs. Graphs are usually represented by
G = (V, E), where V is the set vertices and
E is the set of Edges.
• Operations Performed:
• Searching
• Insertion
• deletion
20. Types of Data Structure ...
Undirected Graph: A graph
whose edges are unordered
pair of vertices. That is each
edge connects two vertices.
In an undirected graph, direction
is not important, if the path is
available, it can be traversed in
any direction.
zaid shabbir
21. Types of Data Structure ...
Directed Graph: In directed graph a directional
edge connect two node/vertex. If there is one edge
from one vertex to other then only this path can be
followed.
22. Selecting a Data Structure
●
●
●
Analyze the problem to determine the resource
constraints a solution must meet.
Determine the basic operations that must be
supported. Quantify the resource constraints
for each operation.
Select the data structure that best meets these
requirements.