SlideShare a Scribd company logo
1
The end of this session, You will be able to,
Explain what is Data Structure(DS) and important of
DS.
Define the Primitives operation on DS.
Differentiate the classification of DS.
Explain the Time Complexity of an algorithm.
Calculate the Time Complexity of a given algorithm.
2
A computer is a programmable data processor that accepts
input and instructions to process the input (program) and
generates the required output.
3
Data
Structure
Algorithm
4
Data are values or a set of values
 Data item refers to single unit of values
Group item :
Data item that can be subdivided into sub item.
Ex Name : First Name, Middle initial and Last
Name
Elementary item:
Data item that can not be sub divided into sub item
Ex :NI card number / Bank Pass Book Number
is treated as single item
5
Collection of data are frequently
organized into a hierarchy of fields,
records and files
6
 Entity : Something that has certain attributes or
properties which may be assigned values, values may be
numeric or non-numeric.
Ex: The employee of an organization
Attributes Values
Name John
Age 33
Sex M
Employee Code 13472
7
Entity with similar attributes ( e.g all employees of an
organization) form an entity set.
Each attribute of an entity set has a range of values [ the
set of possible values that could be assigned to the
particular attribute].
Information: Data with given attribute or processed data.
8
Field is a single elementary unit of
information representing an attribute of an entity.
Record is the collection of field values of a
given entity.
File is the collection of records of the entities in
a given entity set.
9
Name Age Sex Roll Number Branch
A 17 M 109cs0132 CSE
B 18 M 109ee1234 EE
C 19 F 109ce0012 CE
D 20 F 108mm0132 MM
10
Data type refers to the kind of data a variable may store.
Whenever we try to implement any algorithm in some
programming language, we need variables.
A variable may have any value as per the facilities
provided by that language.
int, float, char, double, long double, etc.
Data type is a term that specifies the type of data that a
variable may hold in the programming language. 11
In general, languages have their built-in data types.
However, they also allow the user to define his or her own
data types, called user-defined data types, using the built-
in data types; for example, in the C/C++ languages, int,
float, and char are built-in data types.
Using these built-in data types, we can design (define) our
own data types by means of structures, unions, and
classes.
12
Data structure is a specialized format for organizing,
processing, retrieving and storing data.
The logical or mathematical model of a
particular organization of data.
The term data structure refers to the organization of data
elements and the interrelationships among them.
13
A data structure is a set of domains D, a designated
domain d ( D), a set of functions F, and a set of axioms A.
The triple structure (D, F, A) denotes the data structure
with the following elements:
 Domain (D) This is the range of values that the data may have.
 Functions (F) This is the set of operations for the data. We must
specify a set of operations for a data structure to operate on.
 Axioms (A) This is a set of rules with which the different
operations belonging to F can actually be implemented. 14
Abstraction allows us to organize the complexity of a task
by focusing on logical properties of data and actions rather
than on the implementation details.
Logical properties refer to the ‘what’ and implementation
details refer to the ‘how’. The abstraction is at the
procedural and data level.
Data abstraction is the separation of logical properties of
the data from details of how the data is represented.
Procedural abstraction means separation of the logical
properties of action from implementation.
15
We defined a data structure as a way of organizing data
that specifies
1. a set of data elements, that is, a data object.
2. a set of operations that are applied to this data object.
These two sets form a mathematical construct that may be
implemented using a particular programming language.
16
Data appearing in DS are processed by means
of certain operation.
Particular DS one chooses for a given
situation depends largely on the frequency with
which specific operations are performed.
17
Traversing: Accessing each record exactly once
so that certain items in the record may be
processed [ Also known as Visiting the record].
Searching: Finding the location of the record
with a given key value, or finding the locations of
all record which satisfy one or more conditions.
18
Inserting : Adding a new record to the structure.
Deleting : Removing a record from the structure
19
20
21
The success of a software project often
depends upon the choices made in the
representation of the data and the choice of
algorithms, and hence we need better
methods to describe and process the data.
22
• Time complexity of an algorithm signifies the
total time required by the program to run till
its completion.
• The time complexity of algorithms is most
commonly expressed using the big O
notation.
23
• Time Complexity is most commonly estimated by
counting the number of elementary functions performed
by the algorithm.
• And since the algorithm's performance may vary with
different types of input data, hence for an algorithm we
usually use the worst-case Time complexity of an
algorithm because that is the maximum time taken for
any input size.
24
Using the RAM model of computation, we can
count how many steps our algorithm will take on
any given input instance by simply executing it on
the given input.
 However, to really understand how good or bad an
algorithm is, we must know how it works
over all instances.
25
The worst-case complexity of the algorithm is the function
defined by the maximum number of steps taken on any
instance of size n. It represents the curve passing through
the highest point of each column.
The best-case complexity of the algorithm is the function
defined by the minimum number of steps taken on any
instance of size n. It represents the curve passing through
the lowest point of each column.
Finally, the average-case complexity of the algorithm is
the function defined by the average number of steps taken
on any instance of size n. 26
27
statement;
• Above we have a single statement. Its Time
Complexity will be Constant. The running time
of the statement will not change in relation to N.
28
 Consider the following function:
System.out.println(number);
if(day = 1){
System.out.println(“Monday”);
}
.
.
10 million lines of code
}
Time complexity = 10 million time constant
= O(1)
29
for(i=0; i < N; i++)
{
statement;
}
The time complexity for the above algorithm will be
Linear. The running time of the loop is directly
proportional to N. When N doubles, so does the running
time.
30
31
MATRIX, N-BY-1
VECTOR, MULTIPLY
Y = zeros(N,1);
for i=1:N
Y(i) = 0.0;
for j=1:N
Y(i) = Y(i) + A(i,j)*x(j);
end
end
initialize space, c1N
initialize “for” loop, c2N
Scalar assignment, c3
initialize “for” loop, c2N
(3 accesses, 1 add, 1 multiply)
c4
End of loop, return/exit, c5
End of loop, return/exit, c5
Total = c1N+c2N+N(c3+c2N+N(c4+c5)+c5)
= (c2+c4+c5)N2 + (c1+c2+c3+c5)N
= c6N2 + c7N
N
times
N
times
Time complexity of an algorithm[O(N2)]
32
33
fun(int n)
{
int i,j;
for(i=n; i<1; i=i/2)
{
j = n;
while(j>1)
{
j=j/2;
}
}
}
TIME COMPLEXITY OF AN ALGORITHM[O(LOG2(N)]
i = n n/2 n/22 n/23 n/2k
n< 2k
log n < log 2k
log2
n < log2
2k
34
for(int n)
{
int I,j:
for(i=1; i<n; i=i*i)
{
i++;
j=n;
while(j>0)
{
j=j/3;
}
}
}
35
fun(int n)
{
int I,j,k;
for(i=1; i<n; i++)
{
for(j=1; j<n; j=j+2)
{
for(k=10; k>0; k=k-3)
{
printf(“Hello”);
}
}
}
}
36
37

More Related Content

Similar to Introduction to Data structure and algorithm.pptx (20)

PPTX
Chapter 1- IT.pptx
ssuserb78e291
 
PPTX
Lecture 1.pptx
SisayNegash4
 
PPT
Data Structure and Algorithm chapter two, This material is for Data Structure...
bekidea
 
PPT
DATA STRUCTURE AND ALGORITHMS
removed_8057d320f6c8601c14a895598b86eacb
 
PPT
algo 1.ppt
example43
 
PDF
jn;lm;lkm';m';;lmppt of data structure.pdf
VinayNassa3
 
PDF
Iare ds ppt_3
AlugatiRajitha
 
PPTX
data structure and algoriythm pres.pptxD
dubaay100
 
PDF
Unit 1 OF DS FOR AI DS BTRCH OF DS FOR AI DS BTRCH .pdf
prathamsingh33
 
PDF
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Axmedcarb
 
PPTX
19. Data Structures and Algorithm Complexity
Intro C# Book
 
PPTX
19. Java data structures algorithms and complexity
Intro C# Book
 
PPTX
Lecture 1 and 2
SaheedTundeZubairSTA
 
PDF
Data_structure using C-Adi.pdf
Prof. Dr. K. Adisesha
 
PPTX
Data structure and algorithm
Trupti Agrawal
 
PPTX
Chapter two data structure and algorthms.pptx
wubieabiye2020
 
PPTX
Chapter 1 - Introduction to data structure.pptx
gadisaAdamu
 
PDF
Data structure and algorithm Chapter_1.pdf
tasheebedane
 
PDF
Data structure and Alogorithm analysis unit one
DawitAbera8
 
PPTX
Chapter 1 Data structure.pptx
wondmhunegn
 
Chapter 1- IT.pptx
ssuserb78e291
 
Lecture 1.pptx
SisayNegash4
 
Data Structure and Algorithm chapter two, This material is for Data Structure...
bekidea
 
DATA STRUCTURE AND ALGORITHMS
removed_8057d320f6c8601c14a895598b86eacb
 
algo 1.ppt
example43
 
jn;lm;lkm';m';;lmppt of data structure.pdf
VinayNassa3
 
Iare ds ppt_3
AlugatiRajitha
 
data structure and algoriythm pres.pptxD
dubaay100
 
Unit 1 OF DS FOR AI DS BTRCH OF DS FOR AI DS BTRCH .pdf
prathamsingh33
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Axmedcarb
 
19. Data Structures and Algorithm Complexity
Intro C# Book
 
19. Java data structures algorithms and complexity
Intro C# Book
 
Lecture 1 and 2
SaheedTundeZubairSTA
 
Data_structure using C-Adi.pdf
Prof. Dr. K. Adisesha
 
Data structure and algorithm
Trupti Agrawal
 
Chapter two data structure and algorthms.pptx
wubieabiye2020
 
Chapter 1 - Introduction to data structure.pptx
gadisaAdamu
 
Data structure and algorithm Chapter_1.pdf
tasheebedane
 
Data structure and Alogorithm analysis unit one
DawitAbera8
 
Chapter 1 Data structure.pptx
wondmhunegn
 

Recently uploaded (20)

PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Advancing WebDriver BiDi support in WebKit
Igalia
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
July Patch Tuesday
Ivanti
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Advancing WebDriver BiDi support in WebKit
Igalia
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
July Patch Tuesday
Ivanti
 
Ad

Introduction to Data structure and algorithm.pptx

  • 1. 1
  • 2. The end of this session, You will be able to, Explain what is Data Structure(DS) and important of DS. Define the Primitives operation on DS. Differentiate the classification of DS. Explain the Time Complexity of an algorithm. Calculate the Time Complexity of a given algorithm. 2
  • 3. A computer is a programmable data processor that accepts input and instructions to process the input (program) and generates the required output. 3
  • 5. Data are values or a set of values  Data item refers to single unit of values Group item : Data item that can be subdivided into sub item. Ex Name : First Name, Middle initial and Last Name Elementary item: Data item that can not be sub divided into sub item Ex :NI card number / Bank Pass Book Number is treated as single item 5
  • 6. Collection of data are frequently organized into a hierarchy of fields, records and files 6
  • 7.  Entity : Something that has certain attributes or properties which may be assigned values, values may be numeric or non-numeric. Ex: The employee of an organization Attributes Values Name John Age 33 Sex M Employee Code 13472 7
  • 8. Entity with similar attributes ( e.g all employees of an organization) form an entity set. Each attribute of an entity set has a range of values [ the set of possible values that could be assigned to the particular attribute]. Information: Data with given attribute or processed data. 8
  • 9. Field is a single elementary unit of information representing an attribute of an entity. Record is the collection of field values of a given entity. File is the collection of records of the entities in a given entity set. 9
  • 10. Name Age Sex Roll Number Branch A 17 M 109cs0132 CSE B 18 M 109ee1234 EE C 19 F 109ce0012 CE D 20 F 108mm0132 MM 10
  • 11. Data type refers to the kind of data a variable may store. Whenever we try to implement any algorithm in some programming language, we need variables. A variable may have any value as per the facilities provided by that language. int, float, char, double, long double, etc. Data type is a term that specifies the type of data that a variable may hold in the programming language. 11
  • 12. In general, languages have their built-in data types. However, they also allow the user to define his or her own data types, called user-defined data types, using the built- in data types; for example, in the C/C++ languages, int, float, and char are built-in data types. Using these built-in data types, we can design (define) our own data types by means of structures, unions, and classes. 12
  • 13. Data structure is a specialized format for organizing, processing, retrieving and storing data. The logical or mathematical model of a particular organization of data. The term data structure refers to the organization of data elements and the interrelationships among them. 13
  • 14. A data structure is a set of domains D, a designated domain d ( D), a set of functions F, and a set of axioms A. The triple structure (D, F, A) denotes the data structure with the following elements:  Domain (D) This is the range of values that the data may have.  Functions (F) This is the set of operations for the data. We must specify a set of operations for a data structure to operate on.  Axioms (A) This is a set of rules with which the different operations belonging to F can actually be implemented. 14
  • 15. Abstraction allows us to organize the complexity of a task by focusing on logical properties of data and actions rather than on the implementation details. Logical properties refer to the ‘what’ and implementation details refer to the ‘how’. The abstraction is at the procedural and data level. Data abstraction is the separation of logical properties of the data from details of how the data is represented. Procedural abstraction means separation of the logical properties of action from implementation. 15
  • 16. We defined a data structure as a way of organizing data that specifies 1. a set of data elements, that is, a data object. 2. a set of operations that are applied to this data object. These two sets form a mathematical construct that may be implemented using a particular programming language. 16
  • 17. Data appearing in DS are processed by means of certain operation. Particular DS one chooses for a given situation depends largely on the frequency with which specific operations are performed. 17
  • 18. Traversing: Accessing each record exactly once so that certain items in the record may be processed [ Also known as Visiting the record]. Searching: Finding the location of the record with a given key value, or finding the locations of all record which satisfy one or more conditions. 18
  • 19. Inserting : Adding a new record to the structure. Deleting : Removing a record from the structure 19
  • 20. 20
  • 21. 21
  • 22. The success of a software project often depends upon the choices made in the representation of the data and the choice of algorithms, and hence we need better methods to describe and process the data. 22
  • 23. • Time complexity of an algorithm signifies the total time required by the program to run till its completion. • The time complexity of algorithms is most commonly expressed using the big O notation. 23
  • 24. • Time Complexity is most commonly estimated by counting the number of elementary functions performed by the algorithm. • And since the algorithm's performance may vary with different types of input data, hence for an algorithm we usually use the worst-case Time complexity of an algorithm because that is the maximum time taken for any input size. 24
  • 25. Using the RAM model of computation, we can count how many steps our algorithm will take on any given input instance by simply executing it on the given input.  However, to really understand how good or bad an algorithm is, we must know how it works over all instances. 25
  • 26. The worst-case complexity of the algorithm is the function defined by the maximum number of steps taken on any instance of size n. It represents the curve passing through the highest point of each column. The best-case complexity of the algorithm is the function defined by the minimum number of steps taken on any instance of size n. It represents the curve passing through the lowest point of each column. Finally, the average-case complexity of the algorithm is the function defined by the average number of steps taken on any instance of size n. 26
  • 27. 27
  • 28. statement; • Above we have a single statement. Its Time Complexity will be Constant. The running time of the statement will not change in relation to N. 28
  • 29.  Consider the following function: System.out.println(number); if(day = 1){ System.out.println(“Monday”); } . . 10 million lines of code } Time complexity = 10 million time constant = O(1) 29
  • 30. for(i=0; i < N; i++) { statement; } The time complexity for the above algorithm will be Linear. The running time of the loop is directly proportional to N. When N doubles, so does the running time. 30
  • 31. 31
  • 32. MATRIX, N-BY-1 VECTOR, MULTIPLY Y = zeros(N,1); for i=1:N Y(i) = 0.0; for j=1:N Y(i) = Y(i) + A(i,j)*x(j); end end initialize space, c1N initialize “for” loop, c2N Scalar assignment, c3 initialize “for” loop, c2N (3 accesses, 1 add, 1 multiply) c4 End of loop, return/exit, c5 End of loop, return/exit, c5 Total = c1N+c2N+N(c3+c2N+N(c4+c5)+c5) = (c2+c4+c5)N2 + (c1+c2+c3+c5)N = c6N2 + c7N N times N times Time complexity of an algorithm[O(N2)] 32
  • 33. 33
  • 34. fun(int n) { int i,j; for(i=n; i<1; i=i/2) { j = n; while(j>1) { j=j/2; } } } TIME COMPLEXITY OF AN ALGORITHM[O(LOG2(N)] i = n n/2 n/22 n/23 n/2k n< 2k log n < log 2k log2 n < log2 2k 34
  • 35. for(int n) { int I,j: for(i=1; i<n; i=i*i) { i++; j=n; while(j>0) { j=j/3; } } } 35
  • 36. fun(int n) { int I,j,k; for(i=1; i<n; i++) { for(j=1; j<n; j=j+2) { for(k=10; k>0; k=k-3) { printf(“Hello”); } } } } 36
  • 37. 37