SlideShare una empresa de Scribd 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

Más contenido relacionado

Similar a Introduction to Data structure and algorithm.pptx

Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
Rai University
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
Rai University
 
Lec1
Lec1Lec1
Lec1
Lec1Lec1
Lec1
Saad Gabr
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
Rai University
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure
Prof Ansari
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Axmedcarb
 
Lecture#1(Algorithmic Notations).ppt
Lecture#1(Algorithmic Notations).pptLecture#1(Algorithmic Notations).ppt
Lecture#1(Algorithmic Notations).ppt
MuhammadTalhaAwan1
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
example43
 
DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS
Adams Sidibe
 
Chapter 1 Data structure.pptx
Chapter 1 Data structure.pptxChapter 1 Data structure.pptx
Chapter 1 Data structure.pptx
wondmhunegn
 
DATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTESDATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTES
Aniruddha Paul
 
Ds
DsDs
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptx
skilljiolms
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
Nimmi Weeraddana
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
JohnStuart83
 
Lecture 1 and 2
Lecture 1 and 2Lecture 1 and 2
Lecture 1 and 2
SaheedTundeZubairSTA
 
Bt0065
Bt0065Bt0065
Bt0065
Simpaly Jha
 
B T0065
B T0065B T0065
B T0065
Simpaly Jha
 
Introduction to DS.pptx
Introduction to DS.pptxIntroduction to DS.pptx
Introduction to DS.pptx
OnkarModhave
 

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

Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
 
Lec1
Lec1Lec1
Lec1
 
Lec1
Lec1Lec1
Lec1
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
 
Lecture#1(Algorithmic Notations).ppt
Lecture#1(Algorithmic Notations).pptLecture#1(Algorithmic Notations).ppt
Lecture#1(Algorithmic Notations).ppt
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
 
DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS
 
Chapter 1 Data structure.pptx
Chapter 1 Data structure.pptxChapter 1 Data structure.pptx
Chapter 1 Data structure.pptx
 
DATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTESDATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTES
 
Ds
DsDs
Ds
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptx
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Lecture 1 and 2
Lecture 1 and 2Lecture 1 and 2
Lecture 1 and 2
 
Bt0065
Bt0065Bt0065
Bt0065
 
B T0065
B T0065B T0065
B T0065
 
Introduction to DS.pptx
Introduction to DS.pptxIntroduction to DS.pptx
Introduction to DS.pptx
 

Último

Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!
GDSC PJATK
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
Pravash Chandra Das
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
flufftailshop
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
saastr
 

Último (20)

Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
 

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