Data Structures & Algorithms
Dr. Devyani Jadhav
Course Instructor
Department of AIML
Sanjivani Rural Education Society’s
Sanjivani University, Kopargaon 423601
School of Engineering & Technology
Department of Artificial Intelligence & Machine Learning
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 2
Data Structure
Data Structure
Types of Data Structure
 Primitive and Non-primitive
 Static and Dynamic
 Linear and Non-linear
 Persistent and ephemeral data structures
Data Structures & Algorithm
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 3
Learning Outcome
 Students will be to understand the Data Structure.
 Students will be able to distinguish the Static and Dynamic data
struture, Primitive and Non-primitive
Data Structures & Algorithm
Reference Book
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 4
Data Structure
 Data structure is a way of storing and organizing data efficiently such
that the required operations on them can be performed efficiently to
time and memory.
 Types:
 Static and Dynamic
 Primitive and Non-primitive
 Linear and Non-linear
 Persistent and ephemeral data structures
Data Structures & Algorithm
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 5
Data Structure
 Data structure is a way of storing and organizing data efficiently such
that the required operations on them can be performed efficiently to
time and memory.
 Types:
 Static and Dynamic
 Primitive and Non-primitive
 Linear and Non-linear
 Persistent and ephemeral data structures
Data Structures & Algorithm
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 6
Data Structure: Primitive Vs Non-
Primitive
Data Structures & Algorithm
Data Structure
Primitive
Non Primitive
Stack Queue
Linear Data
Structure
Non Linear Data
Structure
Linked List
Array
real character
Boolean
integer
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 7
Data Structure: Primitive Vs Non-
Primitive
Data Structures & Algorithm
Primitive Data Type Non-Primitive Data Type
Predefined types of data not defined by the programming language
supported by the programming
language
Created by the programmer.
integer, character, and string are all
primitive data types
They are sometimes called "reference
variables," or "object references," since they
reference a memory location, which stores the
data
Programmers can use these data types
when creating variables in their
programs
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 8
Data Structure: Primitive Vs Non-
Primitive
Data Structures & Algorithm
Primitive Data Type Non-Primitive Data Type
The basic data types that are
available in most of the
programming languages
The data types that are derived from
primary data types
used to represent single values. used to store group of values.
Example:
Integer, string, Boolean, Floating
Example:
Arrays, Structure, Union
linked list, Stacks, Queue etc
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 9
Data Structure: 2. Static and
Dynamic
Data Structures & Algorithm
 Static Data Structure
a. Memory is allotted at compile
time
b. Cannot change size, once
created.
c. Provides more easier access to
elements through Index
d. Element can access directly
e. Not Flexible
f. Example: Array
 Dynamic Data Structure
a. Memory is allotted at Run time
b. size can be updated during run
time
c. Not provide easier access
d. Not access element directly
e. More Flexible
f. Example: Linked List
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 10
Data Structure: 2. Static and
Dynamic
Data Structures & Algorithm
Array Linked List
Contains a collection of similar type data
elements
considered as non-primitive data structure
contains a collection of unordered linked
elements known as nodes.
Direct Access to the elements through
Index.
Start from the First Node / head and
Traverse the list through until you get to the
element.
Accessing an element in an array is fast, Linked list takes linear time, so it is quite a bit
slower
Operations like insertion and deletion in
arrays consume a lot of time
Performance of insertion and deletion operations
in Linked lists is fast.
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 11
Data Structure: 2. Static and
Dynamic
Data Structures & Algorithm
Array Linked List
Arrays are of fixed size. Linked lists are dynamic and flexible and can
expand and contract its size.
Memory is assigned during compile time Allocated during execution or runtime.
Elements are stored consecutively in arrays Elements are stored randomly in Linked lists.
The requirement of memory is less due to
actual data being stored within the index in
the array
It need for more memory in Linked Lists due to
storage of additional next and previous
referencing elements.
Memory utilization is inefficient in the
array.
Memory utilization is efficient in the linked list.
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 12
Data Structure: 3. Linear and Non-
Linear
Data Structures & Algorithm
Data Structure
Linear Non-Linear
Linked List
Stack
Array
Queue
Tree Graph
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 13
Data Structure: 3. Linear and Non-
Linear
Data Structures & Algorithm
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 14
Data Structure: Linear
 Linear: the data elements construct a sequence of a linear list.
 Every element have one successor and one predecessor
 adjacently attached to each other and in a specified order.
 Consumes linear memory space:
 the data elements are required to store in a sequential manner in the
memory.
 The traversal of data elements done sequentially
 Insertion or deletion are done sequentially
 The data element are visited sequentially where only a single element
can be directly reached
Data Structures & Algorithm
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 15
Data Structure: Linear
Data Structures & Algorithm
 Array: An array is a group of a definite number of homogeneous
elements stored consecutive memory locations.
 Each element is at fixed distance apart.
 Linked List: A group of a definite number of homogeneous elements
not stored consecutively.
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 16
Linear Data Structure
Stack: ordered collection of the elements like an array but
 Stack follows LIFO (Last in first out) order
Queue: ordered collection of the elements like an array but
 Queue employ FIFO (First in first out) to insert and delete the elements.
Data Structures & Algorithm
D
C
B
A
E
D
C
B
A
top
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 17
Non-Linear Data Structure
Data Structures & Algorithm
 Graph:
 A graph data structure
organizes and stores the data
elements in a hierarchical
relationship
 All elements are connected to
each other
 Tree:
 A tree data structure organizes
and stores the data elements in a
hierarchical relationship
 Parent to child relation ship
a b
c
d e
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 18
Non-Linear Data Structure
 It does not arrange the data consecutively rather it is arranged in
sorted order.
 Every element have more than one successor and predecessor
 element exhibiting the hierarchical relationship which involves the
relationship between the child, parent, and grandparent.
 The traversal of data elements and insertion or deletion are not done
sequentially.
 It utilizes the memory efficiently.
 It does not require the memory declaration in advance.
Data Structures & Algorithm
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 19
Linear vs Non-Linear Data
Structure
Data Structures & Algorithm
Basis for
comparison
Linear data structure Non-linear data structure
the data is organized in a linear order in
which elements are linked one after the
other
data elements are not stored in a
sequential manner rather the
elements are hierarchically related
Basic Every item is related to its previous and
next item.
very item is attached with many other
items.
Data is arranged in linear sequence. Data is not arranged in sequence.
Traversing of the
data
All data elements can be read in one time
(single run).
Traversing of data elements in one go
is not possible
Ease of
implementation
Easy to Implement Complex
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 20
Data Structures & Algorithm
Basis for
comparison
Linear data structure Non-linear data structure
Levels involved Single Level Multilple level
A single level of elements is
incorporated in the linear data
structure
non-linear data structure
involves multiple levels
Examples Array, queue, stack, linked list, Tree and graph.
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 21
Data Structure: 4. Persistent vs
Ephemeral
 A persistent data structure:
 always preserves the previous version of itself when it is modified.
 Any operations on such data structure creates two version of data
structure.
 Retain their previous state and modifications can be done by
performing some operations.
 Considered as ‘immutable’ as updates are not in-place.
Data Structures & Algorithm
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 22
Summary
• Classification of Data Structure
• Primitive Vs Non-Primitive
• Static Vs Dynamic
• Linear Vs Non-Linear
• Persistent vs Ephemeral
Data Structures & Algorithm
Dr. Devyani Jadhav, Dept of AIML, Sanjivani University 23
Thank you!!
Data Structures & Algorithm
Happy
Learning!!

Classification of Data Structure: Primitive Vs Non Primitive, Static Vs Daynamic

  • 1.
    Data Structures &Algorithms Dr. Devyani Jadhav Course Instructor Department of AIML Sanjivani Rural Education Society’s Sanjivani University, Kopargaon 423601 School of Engineering & Technology Department of Artificial Intelligence & Machine Learning
  • 2.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 2 Data Structure Data Structure Types of Data Structure  Primitive and Non-primitive  Static and Dynamic  Linear and Non-linear  Persistent and ephemeral data structures Data Structures & Algorithm
  • 3.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 3 Learning Outcome  Students will be to understand the Data Structure.  Students will be able to distinguish the Static and Dynamic data struture, Primitive and Non-primitive Data Structures & Algorithm Reference Book
  • 4.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 4 Data Structure  Data structure is a way of storing and organizing data efficiently such that the required operations on them can be performed efficiently to time and memory.  Types:  Static and Dynamic  Primitive and Non-primitive  Linear and Non-linear  Persistent and ephemeral data structures Data Structures & Algorithm
  • 5.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 5 Data Structure  Data structure is a way of storing and organizing data efficiently such that the required operations on them can be performed efficiently to time and memory.  Types:  Static and Dynamic  Primitive and Non-primitive  Linear and Non-linear  Persistent and ephemeral data structures Data Structures & Algorithm
  • 6.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 6 Data Structure: Primitive Vs Non- Primitive Data Structures & Algorithm Data Structure Primitive Non Primitive Stack Queue Linear Data Structure Non Linear Data Structure Linked List Array real character Boolean integer
  • 7.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 7 Data Structure: Primitive Vs Non- Primitive Data Structures & Algorithm Primitive Data Type Non-Primitive Data Type Predefined types of data not defined by the programming language supported by the programming language Created by the programmer. integer, character, and string are all primitive data types They are sometimes called "reference variables," or "object references," since they reference a memory location, which stores the data Programmers can use these data types when creating variables in their programs
  • 8.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 8 Data Structure: Primitive Vs Non- Primitive Data Structures & Algorithm Primitive Data Type Non-Primitive Data Type The basic data types that are available in most of the programming languages The data types that are derived from primary data types used to represent single values. used to store group of values. Example: Integer, string, Boolean, Floating Example: Arrays, Structure, Union linked list, Stacks, Queue etc
  • 9.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 9 Data Structure: 2. Static and Dynamic Data Structures & Algorithm  Static Data Structure a. Memory is allotted at compile time b. Cannot change size, once created. c. Provides more easier access to elements through Index d. Element can access directly e. Not Flexible f. Example: Array  Dynamic Data Structure a. Memory is allotted at Run time b. size can be updated during run time c. Not provide easier access d. Not access element directly e. More Flexible f. Example: Linked List
  • 10.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 10 Data Structure: 2. Static and Dynamic Data Structures & Algorithm Array Linked List Contains a collection of similar type data elements considered as non-primitive data structure contains a collection of unordered linked elements known as nodes. Direct Access to the elements through Index. Start from the First Node / head and Traverse the list through until you get to the element. Accessing an element in an array is fast, Linked list takes linear time, so it is quite a bit slower Operations like insertion and deletion in arrays consume a lot of time Performance of insertion and deletion operations in Linked lists is fast.
  • 11.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 11 Data Structure: 2. Static and Dynamic Data Structures & Algorithm Array Linked List Arrays are of fixed size. Linked lists are dynamic and flexible and can expand and contract its size. Memory is assigned during compile time Allocated during execution or runtime. Elements are stored consecutively in arrays Elements are stored randomly in Linked lists. The requirement of memory is less due to actual data being stored within the index in the array It need for more memory in Linked Lists due to storage of additional next and previous referencing elements. Memory utilization is inefficient in the array. Memory utilization is efficient in the linked list.
  • 12.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 12 Data Structure: 3. Linear and Non- Linear Data Structures & Algorithm Data Structure Linear Non-Linear Linked List Stack Array Queue Tree Graph
  • 13.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 13 Data Structure: 3. Linear and Non- Linear Data Structures & Algorithm
  • 14.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 14 Data Structure: Linear  Linear: the data elements construct a sequence of a linear list.  Every element have one successor and one predecessor  adjacently attached to each other and in a specified order.  Consumes linear memory space:  the data elements are required to store in a sequential manner in the memory.  The traversal of data elements done sequentially  Insertion or deletion are done sequentially  The data element are visited sequentially where only a single element can be directly reached Data Structures & Algorithm
  • 15.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 15 Data Structure: Linear Data Structures & Algorithm  Array: An array is a group of a definite number of homogeneous elements stored consecutive memory locations.  Each element is at fixed distance apart.  Linked List: A group of a definite number of homogeneous elements not stored consecutively.
  • 16.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 16 Linear Data Structure Stack: ordered collection of the elements like an array but  Stack follows LIFO (Last in first out) order Queue: ordered collection of the elements like an array but  Queue employ FIFO (First in first out) to insert and delete the elements. Data Structures & Algorithm D C B A E D C B A top
  • 17.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 17 Non-Linear Data Structure Data Structures & Algorithm  Graph:  A graph data structure organizes and stores the data elements in a hierarchical relationship  All elements are connected to each other  Tree:  A tree data structure organizes and stores the data elements in a hierarchical relationship  Parent to child relation ship a b c d e
  • 18.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 18 Non-Linear Data Structure  It does not arrange the data consecutively rather it is arranged in sorted order.  Every element have more than one successor and predecessor  element exhibiting the hierarchical relationship which involves the relationship between the child, parent, and grandparent.  The traversal of data elements and insertion or deletion are not done sequentially.  It utilizes the memory efficiently.  It does not require the memory declaration in advance. Data Structures & Algorithm
  • 19.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 19 Linear vs Non-Linear Data Structure Data Structures & Algorithm Basis for comparison Linear data structure Non-linear data structure the data is organized in a linear order in which elements are linked one after the other data elements are not stored in a sequential manner rather the elements are hierarchically related Basic Every item is related to its previous and next item. very item is attached with many other items. Data is arranged in linear sequence. Data is not arranged in sequence. Traversing of the data All data elements can be read in one time (single run). Traversing of data elements in one go is not possible Ease of implementation Easy to Implement Complex
  • 20.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 20 Data Structures & Algorithm Basis for comparison Linear data structure Non-linear data structure Levels involved Single Level Multilple level A single level of elements is incorporated in the linear data structure non-linear data structure involves multiple levels Examples Array, queue, stack, linked list, Tree and graph.
  • 21.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 21 Data Structure: 4. Persistent vs Ephemeral  A persistent data structure:  always preserves the previous version of itself when it is modified.  Any operations on such data structure creates two version of data structure.  Retain their previous state and modifications can be done by performing some operations.  Considered as ‘immutable’ as updates are not in-place. Data Structures & Algorithm
  • 22.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 22 Summary • Classification of Data Structure • Primitive Vs Non-Primitive • Static Vs Dynamic • Linear Vs Non-Linear • Persistent vs Ephemeral Data Structures & Algorithm
  • 23.
    Dr. Devyani Jadhav,Dept of AIML, Sanjivani University 23 Thank you!! Data Structures & Algorithm Happy Learning!!