Unit 1 Introduction, Basic Concepts
Unit 1 Introduction, Basic Concepts
USING PYTHON
UNIT-1 LINEAR DATA
STRUCTURES
INTRODUCTION TO DATA
STRUCTURES
Basic Terminologies
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.
zaid shabbir
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.
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
• 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.
Classification of Data structures
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
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.
Pros: Fast Access
Memory consumption is minimal
Cons: Insertion and deletion is complicated
Types of Data Structure ...
zaid shabbir
• 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
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
• 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.
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.
• 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.
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.
• 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.
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.
•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
Types of Data Structure ...
zaid shabbir
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.
Selecting a Data Structure