SlideShare ist ein Scribd-Unternehmen logo
1 von 37
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

Weitere ähnliche Inhalte

Ähnlich wie 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 structureRai 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 structureRai University
 
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 structureRai 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.pdfAxmedcarb
 
Lecture#1(Algorithmic Notations).ppt
Lecture#1(Algorithmic Notations).pptLecture#1(Algorithmic Notations).ppt
Lecture#1(Algorithmic Notations).pptMuhammadTalhaAwan1
 
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.pptxwondmhunegn
 
DATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTESDATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTESAniruddha Paul
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxskilljiolms
 
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).pdNimmi Weeraddana
 
Introduction to DS.pptx
Introduction to DS.pptxIntroduction to DS.pptx
Introduction to DS.pptxOnkarModhave
 

Ähnlich wie 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
 

Kürzlich hochgeladen

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Kürzlich hochgeladen (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

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