SlideShare uma empresa Scribd logo
1 de 37
Introduction to Data Structure
& Algorithms
Akhil Kaushik
Asstt. Prof., CE Deptt.,
TIT Bhiwani
Good Computer Program
• A computer program is a series of instructions to carry out a
particular task written in a language that a computer can
understand.
• There are a number of features for a good program:-
– Run efficiently and correctly
– Have a user friendly interface
– Be easy to read and understand
– Be easy to debug
– Be easy to modify
– Be easy to maintain
Good Computer Program
• Programs consists of two things: Algorithms and
data structures.
• A good program is a combination of both
algorithm and a data structure.
• An algorithm is a step by step recipe for solving
an instance of a problem.
What are Data Structures?
• Data structures defines a way of organizing all
data items that consider not only the elements
stored but also stores the relationship
between the elements.
• A data structure represents the logical
relationship that exists between individual
elements of data to carry out certain tasks.
What are Data Structures?
• In simple language, Data Structures are
structures programmed to store ordered data,
so that various operations can be performed
on it easily.
• Ex: Store runs according to a Batsman’s
name.
Why study Data Structures?
• To identify and develop useful mathematical
entities and operations and to determine what
class of problem can be solved by them.
• To determine representation of abstract
entities and to implement the abstract
operations on these representations
Data Type vs Data Structure
• Data type: data type a set of values that
variable may assume. Int, float, char, double,
Boolean.
• Data Structure: extension of data type i.e.
the implementation of organized data and
operations allowed on data type.
Why study Data Structures?
• DS are used in almost every program or
software.
• DS study is mandatory to develop better
algorithm.
• DS allow management of large database and
internet indexing services.
Why study Data Structures?
Study of DS includes:-
• Logical description of DS
• Implementation of DS
• Quantitative analysis of DS
Why study Data Structures?
Applications of DS are in every are including:-
• DBMS
• SIMULATION
• GRAPHICS
• NETWORK ANALYSIS
• NUMERICAL ANALYSIS
• COMPILER DESIGN
• OPERATING SYSTEM
• ARTIFICAL INTELLIGENCE
Data Structure Classification
Classification can be done on the basis of :-
1. According to nature of size
2. According to its occurrence
3. Primitive and non-primitive
Data Structure Classification
STATIC AND DYNAMIC
1. Static: Here we can store data up to a fixed no.
only.
Ex: array.
2. Dynamic: It allows programmer to change its
size during program execution to add or delete
data.
Ex: linked list, tree, etc.
LINEAR AND NON-LINEAR
1. Linear: Here data is stored in consecutive
memory allocation i.e. - sequentially.
Ex: array, linked list, queue, etc.
2. Non-linear: Here data is in no sequential form and
usually used to identify hierarchical relationship.
Ex: Trees
PRIMITIVE AND NON-PRIMITIVE
PRIMITIVE DATATYPE: These data
types are used to represent single
values.
• Integer: This is used to represent
a number without decimal point.
Ex: 12, 90
• Float and Double: This is used to
represent a number with decimal
point. Ex: 45.1, 67.3
• Character : This is used to
represent single character
Ex: ‘C’, ‘a’
• String: This is used to represent
group of characters.
Ex: “Stephen College"
NON-PRIMITIVE DATATYPES:
The data types that are derived
from primary data types are
known as non-Primitive data
types.
• These data types are used to
store group of values.
• The non-primitive data types
are
– Arrays
– Structure
– Union
– linked list
– Stacks
Homogenous vs Hetrogenous
• Homogenous: DS refer to the data structure
which store same type of elements.
Ex: arrays
• Non-homogenous: DS refer to the data
structure which store data of different type of
elements.
Ex: structure.
Operations on Data Structure
1. Traversing: Accessing each records exactly once so that
certain items in the record may be processed.
2. Searching: Finding the location of a particular record with a
given key value, or finding the location of all records which
satisfy one or more conditions.
3. Inserting: Adding a new record to the structure.
4. Deleting: Removing the record from the structure.
5. Sorting: Managing the data or record in some logical
order(Ascending or descending order).
6. Merging: Combining the record in two different sorted files into
a single sorted file.
7. Create, delete, update, etc.
Algorithms
• An algorithm is a step by step recipe for solving
an instance of a problem.
• An algorithm is a precise procedure for solving a
problem in finite number of steps.
• An algorithm states the actions to be executed
and the order in which these actions are to be
executed.
Algorithms
• An algorithm possesses the following properties:-
– It must be correct.
– It must be composed of a finite number of steps.
– There can be no ambiguity as to which step will be done next.
– It must terminate.
– It takes zero or more inputs
– It should be efficient and flexible
– It should use less memory space as much as possible
– It results in one or more outputs
Various steps in developing
Algorithms
• Devising the Algorithm:- Each step of an algorithm
must be precisely defined and no vague
statements should be used.
– Pseudo code is used to describe the algorithm, in less
formal language than a Programming language
Various steps in developing
Algorithms
• Validating the Algorithm: The proof of correctness
of the algorithm.
– A human must be able to perform each step by giving
the required input, use the algorithm and get the
required output in a finite amount of time.
• Expressing the algorithm: To implement the
algorithm in a programming language.
– The algorithm used should terminate after a finite
number of steps.
Efficiency of an Algorithm
An algorithm should meet three things:-
• It should be independent of the programming
language in which the idea is realized
• Every programmer having enough knowledge
and experience should understand it
• It should be applicable to inputs of all sizes
Efficiency of an Algorithm
• Efficiency of an algorithm denotes the rate at
which an algorithm solves a problem of size ‘n’.
• It is measured by the amount of resources it uses,
the time and the space.
• An algorithm’s complexity is measured by
calculating the time taken and space required for
performing the algorithm.
Space Complexity of an Algorithm
• It is the way in which the amount of storage space
required by an algorithm varies with the size of the
problem to be solved.
• The space occupied by the program is generally by the
following:-
– A fixed amount of memory for the program code.
– A variable amount of memory for variable. This space increases
or decreases depending upon whether the program uses
iterative or recursive procedures.
Space Complexity of an Algorithm
• Instruction Space is the space occupied by the
compiled version of the program.
• Data Space is the space used to hold the
variables , data structures, allocated memory and
other data elements.
• Environment Space is the space used on the run
time stack for each function call.
Time Complexity of an Algorithm
• The way in which the number of steps required by
an algo varies with the size of the problem it is
solving.
Time Complexity of an Algorithm
• It is the amount of time needed by a program
to complete its task.
• The time taken for an algorithm is comprised
of two times:-
– Compilation Time
– Run Time
Time Complexity of an Algorithm
• Compilation time is the time taken to compile an
algorithm.
• While compiling it checks for the syntax and
semantic errors in the program and links it with
the standard libraries, your program has asked to.
• It comes under the domain of computer science
(software dependent).
Time Complexity of an Algorithm
• Runtime is the time to execute the compiled
program.
• Note that run time is calculated only for
executable statements and not for declaration
statements.
• It comes under the domain of electronics
(depends on hardware).
Time Complexity of an Algorithm
• It can be defined for computation of function f() as
a total number of statements that are executed for
computing the value of f(n).
• Time complexity of an algorithm is generally
classified as three types:-
(i) Worst case
(ii) Average Case
(iii) Best Case
Time Complexity of an Algorithm
• Worst Case: It is the longest time that an algorithm will
use over all instances of size ‘n’ for a given problem to
produce a desired result.
– Denoted by Big-Oh (O)
• Average Case: It is the average time(or average space).
– Denoted by theta (Θ).
• Best Case: It is the shortest time (or least space).
– Denoted by Omega(Ω).
Time Complexity of an Algorithm
Time Complexity of an Algorithm
fact ( long n)
{
for (i=1; i<=n; i++)
x=i*x;
return x;
}
• Data Space: i, n and x
• Environment Space: Almost nothing
because the function is called only once.
• The algorithm has a complexity of O(1)
because it does not depend on n.
• No matter how big the problem
becomes, the space complexity remains
the same since the same variables are
used, and the function is called only
once.
Time Complexity of an Algorithm
long fact (long x)
{
if (x<=1)
return(1);
else
return (x * fact(x-1));
}
• Data space : x
• Environment Space: fact() is
called recursively , and so the
amount of space this program
used is based on the size of
the problem.
Measure Algorithms’ Performance
• It needs programs to create ,append, update the
database, print data, permit online enquiry and so
on.
• A Programmer should identify all requirements to
solve the problem like:-
– Type of Programming language
– Narration of the program describing the tasks to be
performed
– Frequency of Processing (hourly, daily, weekly etc)
– Input and output of the program
– Limitations and restrictions for the program
Measure Algorithms’ Performance
• What metric should be used to judge algorithms?
– Length of the program (lines of code)
– Ease of programming (bugs, maintenance)
– Memory required
– Running time
*Running time is the dominant standard.
– Quantifiable and easy to compare
– Often the critical bottleneck
CONTACT ME AT:
Akhil Kaushik
akhilkaushik05@gmail.com
9416910303
CONTACT ME AT:
Akhil Kaushik
akhilkaushik05@gmail.com
9416910303
Thank You !!!

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Python list
Python listPython list
Python list
 
Selection sort
Selection sortSelection sort
Selection sort
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
Python functions
Python functionsPython functions
Python functions
 
Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
 
Binary search
Binary searchBinary search
Binary search
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
Data structure
Data structureData structure
Data structure
 
Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptx
 
Python Interview Questions And Answers
Python Interview Questions And AnswersPython Interview Questions And Answers
Python Interview Questions And Answers
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Python Collections Tutorial | Edureka
Python Collections Tutorial | EdurekaPython Collections Tutorial | Edureka
Python Collections Tutorial | Edureka
 
Python functions
Python functionsPython functions
Python functions
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Iterarators and generators in python
Iterarators and generators in pythonIterarators and generators in python
Iterarators and generators in python
 

Semelhante a Intro to Data Structure & Algorithms

Data structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfData structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfDukeCalvin
 
Basic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - NotesBasic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - NotesOmprakash Chauhan
 
Algorithms and Data Structures
Algorithms and Data StructuresAlgorithms and Data Structures
Algorithms and Data Structuressonykhan3
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithmsiqbalphy1
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxSyed Zaid Irshad
 
Unit 1 abstract data types
Unit 1 abstract data typesUnit 1 abstract data types
Unit 1 abstract data typesLavanyaJ28
 
data structures and its importance
 data structures and its importance  data structures and its importance
data structures and its importance Anaya Zafar
 
Analysis of Algorithms_RR.pptx
Analysis of Algorithms_RR.pptxAnalysis of Algorithms_RR.pptx
Analysis of Algorithms_RR.pptxKarthikR780430
 
Data structure introduction
Data structure introductionData structure introduction
Data structure introductionNavneetSandhu0
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm. Abdul salam
 
part 1 - intorduction data structure 2021 mte.ppt
part 1 -  intorduction data structure  2021 mte.pptpart 1 -  intorduction data structure  2021 mte.ppt
part 1 - intorduction data structure 2021 mte.pptabdoSelem1
 
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.pptxjinkhatima
 
ADS Introduction
ADS IntroductionADS Introduction
ADS IntroductionNagendraK18
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...AntareepMajumder
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdfNayanChandak1
 

Semelhante a Intro to Data Structure & Algorithms (20)

Data structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfData structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdf
 
Basic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - NotesBasic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - Notes
 
Algorithms and Data Structures
Algorithms and Data StructuresAlgorithms and Data Structures
Algorithms and Data Structures
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
Cs 331 Data Structures
Cs 331 Data StructuresCs 331 Data Structures
Cs 331 Data Structures
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
 
Unit 1 abstract data types
Unit 1 abstract data typesUnit 1 abstract data types
Unit 1 abstract data types
 
Lec1.ppt
Lec1.pptLec1.ppt
Lec1.ppt
 
data structures and its importance
 data structures and its importance  data structures and its importance
data structures and its importance
 
Analysis of Algorithms_RR.pptx
Analysis of Algorithms_RR.pptxAnalysis of Algorithms_RR.pptx
Analysis of Algorithms_RR.pptx
 
Data structure introduction
Data structure introductionData structure introduction
Data structure introduction
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
 
part 1 - intorduction data structure 2021 mte.ppt
part 1 -  intorduction data structure  2021 mte.pptpart 1 -  intorduction data structure  2021 mte.ppt
part 1 - intorduction data structure 2021 mte.ppt
 
Unit 1 dsa
Unit 1 dsaUnit 1 dsa
Unit 1 dsa
 
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.pptx
 
ADS Introduction
ADS IntroductionADS Introduction
ADS Introduction
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 

Mais de Akhil Kaushik

Symbol Table, Error Handler & Code Generation
Symbol Table, Error Handler & Code GenerationSymbol Table, Error Handler & Code Generation
Symbol Table, Error Handler & Code GenerationAkhil Kaushik
 
Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler DesignAkhil Kaushik
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free GrammarAkhil Kaushik
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & RecoveryAkhil Kaushik
 
Lexical Analyzer Implementation
Lexical Analyzer ImplementationLexical Analyzer Implementation
Lexical Analyzer ImplementationAkhil Kaushik
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignAkhil Kaushik
 
File Handling Python
File Handling PythonFile Handling Python
File Handling PythonAkhil Kaushik
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity CalculationAkhil Kaushik
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & LoopsAkhil Kaushik
 
Basic programs in Python
Basic programs in PythonBasic programs in Python
Basic programs in PythonAkhil Kaushik
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python ProgrammingAkhil Kaushik
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design BasicsAkhil Kaushik
 
Bootstrapping in Compiler
Bootstrapping in CompilerBootstrapping in Compiler
Bootstrapping in CompilerAkhil Kaushik
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction toolsAkhil Kaushik
 

Mais de Akhil Kaushik (20)

Symbol Table, Error Handler & Code Generation
Symbol Table, Error Handler & Code GenerationSymbol Table, Error Handler & Code Generation
Symbol Table, Error Handler & Code Generation
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler Design
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free Grammar
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & Recovery
 
Symbol Table
Symbol TableSymbol Table
Symbol Table
 
Lexical Analyzer Implementation
Lexical Analyzer ImplementationLexical Analyzer Implementation
Lexical Analyzer Implementation
 
NFA & DFA
NFA & DFANFA & DFA
NFA & DFA
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler Design
 
File Handling Python
File Handling PythonFile Handling Python
File Handling Python
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & Loops
 
Basic programs in Python
Basic programs in PythonBasic programs in Python
Basic programs in Python
 
Python Data-Types
Python Data-TypesPython Data-Types
Python Data-Types
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Bootstrapping in Compiler
Bootstrapping in CompilerBootstrapping in Compiler
Bootstrapping in Compiler
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 

Último

Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 

Último (20)

Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 

Intro to Data Structure & Algorithms

  • 1. Introduction to Data Structure & Algorithms Akhil Kaushik Asstt. Prof., CE Deptt., TIT Bhiwani
  • 2. Good Computer Program • A computer program is a series of instructions to carry out a particular task written in a language that a computer can understand. • There are a number of features for a good program:- – Run efficiently and correctly – Have a user friendly interface – Be easy to read and understand – Be easy to debug – Be easy to modify – Be easy to maintain
  • 3. Good Computer Program • Programs consists of two things: Algorithms and data structures. • A good program is a combination of both algorithm and a data structure. • An algorithm is a step by step recipe for solving an instance of a problem.
  • 4. What are Data Structures? • Data structures defines a way of organizing all data items that consider not only the elements stored but also stores the relationship between the elements. • A data structure represents the logical relationship that exists between individual elements of data to carry out certain tasks.
  • 5. What are Data Structures? • In simple language, Data Structures are structures programmed to store ordered data, so that various operations can be performed on it easily. • Ex: Store runs according to a Batsman’s name.
  • 6. Why study Data Structures? • To identify and develop useful mathematical entities and operations and to determine what class of problem can be solved by them. • To determine representation of abstract entities and to implement the abstract operations on these representations
  • 7. Data Type vs Data Structure • Data type: data type a set of values that variable may assume. Int, float, char, double, Boolean. • Data Structure: extension of data type i.e. the implementation of organized data and operations allowed on data type.
  • 8. Why study Data Structures? • DS are used in almost every program or software. • DS study is mandatory to develop better algorithm. • DS allow management of large database and internet indexing services.
  • 9. Why study Data Structures? Study of DS includes:- • Logical description of DS • Implementation of DS • Quantitative analysis of DS
  • 10. Why study Data Structures? Applications of DS are in every are including:- • DBMS • SIMULATION • GRAPHICS • NETWORK ANALYSIS • NUMERICAL ANALYSIS • COMPILER DESIGN • OPERATING SYSTEM • ARTIFICAL INTELLIGENCE
  • 11. Data Structure Classification Classification can be done on the basis of :- 1. According to nature of size 2. According to its occurrence 3. Primitive and non-primitive
  • 13. STATIC AND DYNAMIC 1. Static: Here we can store data up to a fixed no. only. Ex: array. 2. Dynamic: It allows programmer to change its size during program execution to add or delete data. Ex: linked list, tree, etc.
  • 14. LINEAR AND NON-LINEAR 1. Linear: Here data is stored in consecutive memory allocation i.e. - sequentially. Ex: array, linked list, queue, etc. 2. Non-linear: Here data is in no sequential form and usually used to identify hierarchical relationship. Ex: Trees
  • 15. PRIMITIVE AND NON-PRIMITIVE PRIMITIVE DATATYPE: These data types are used to represent single values. • Integer: This is used to represent a number without decimal point. Ex: 12, 90 • Float and Double: This is used to represent a number with decimal point. Ex: 45.1, 67.3 • Character : This is used to represent single character Ex: ‘C’, ‘a’ • String: This is used to represent group of characters. Ex: “Stephen College" NON-PRIMITIVE DATATYPES: The data types that are derived from primary data types are known as non-Primitive data types. • These data types are used to store group of values. • The non-primitive data types are – Arrays – Structure – Union – linked list – Stacks
  • 16. Homogenous vs Hetrogenous • Homogenous: DS refer to the data structure which store same type of elements. Ex: arrays • Non-homogenous: DS refer to the data structure which store data of different type of elements. Ex: structure.
  • 17. Operations on Data Structure 1. Traversing: Accessing each records exactly once so that certain items in the record may be processed. 2. Searching: Finding the location of a particular record with a given key value, or finding the location of all records which satisfy one or more conditions. 3. Inserting: Adding a new record to the structure. 4. Deleting: Removing the record from the structure. 5. Sorting: Managing the data or record in some logical order(Ascending or descending order). 6. Merging: Combining the record in two different sorted files into a single sorted file. 7. Create, delete, update, etc.
  • 18. Algorithms • An algorithm is a step by step recipe for solving an instance of a problem. • An algorithm is a precise procedure for solving a problem in finite number of steps. • An algorithm states the actions to be executed and the order in which these actions are to be executed.
  • 19. Algorithms • An algorithm possesses the following properties:- – It must be correct. – It must be composed of a finite number of steps. – There can be no ambiguity as to which step will be done next. – It must terminate. – It takes zero or more inputs – It should be efficient and flexible – It should use less memory space as much as possible – It results in one or more outputs
  • 20. Various steps in developing Algorithms • Devising the Algorithm:- Each step of an algorithm must be precisely defined and no vague statements should be used. – Pseudo code is used to describe the algorithm, in less formal language than a Programming language
  • 21. Various steps in developing Algorithms • Validating the Algorithm: The proof of correctness of the algorithm. – A human must be able to perform each step by giving the required input, use the algorithm and get the required output in a finite amount of time. • Expressing the algorithm: To implement the algorithm in a programming language. – The algorithm used should terminate after a finite number of steps.
  • 22. Efficiency of an Algorithm An algorithm should meet three things:- • It should be independent of the programming language in which the idea is realized • Every programmer having enough knowledge and experience should understand it • It should be applicable to inputs of all sizes
  • 23. Efficiency of an Algorithm • Efficiency of an algorithm denotes the rate at which an algorithm solves a problem of size ‘n’. • It is measured by the amount of resources it uses, the time and the space. • An algorithm’s complexity is measured by calculating the time taken and space required for performing the algorithm.
  • 24. Space Complexity of an Algorithm • It is the way in which the amount of storage space required by an algorithm varies with the size of the problem to be solved. • The space occupied by the program is generally by the following:- – A fixed amount of memory for the program code. – A variable amount of memory for variable. This space increases or decreases depending upon whether the program uses iterative or recursive procedures.
  • 25. Space Complexity of an Algorithm • Instruction Space is the space occupied by the compiled version of the program. • Data Space is the space used to hold the variables , data structures, allocated memory and other data elements. • Environment Space is the space used on the run time stack for each function call.
  • 26. Time Complexity of an Algorithm • The way in which the number of steps required by an algo varies with the size of the problem it is solving.
  • 27. Time Complexity of an Algorithm • It is the amount of time needed by a program to complete its task. • The time taken for an algorithm is comprised of two times:- – Compilation Time – Run Time
  • 28. Time Complexity of an Algorithm • Compilation time is the time taken to compile an algorithm. • While compiling it checks for the syntax and semantic errors in the program and links it with the standard libraries, your program has asked to. • It comes under the domain of computer science (software dependent).
  • 29. Time Complexity of an Algorithm • Runtime is the time to execute the compiled program. • Note that run time is calculated only for executable statements and not for declaration statements. • It comes under the domain of electronics (depends on hardware).
  • 30. Time Complexity of an Algorithm • It can be defined for computation of function f() as a total number of statements that are executed for computing the value of f(n). • Time complexity of an algorithm is generally classified as three types:- (i) Worst case (ii) Average Case (iii) Best Case
  • 31. Time Complexity of an Algorithm • Worst Case: It is the longest time that an algorithm will use over all instances of size ‘n’ for a given problem to produce a desired result. – Denoted by Big-Oh (O) • Average Case: It is the average time(or average space). – Denoted by theta (Θ). • Best Case: It is the shortest time (or least space). – Denoted by Omega(Ω).
  • 32. Time Complexity of an Algorithm
  • 33. Time Complexity of an Algorithm fact ( long n) { for (i=1; i<=n; i++) x=i*x; return x; } • Data Space: i, n and x • Environment Space: Almost nothing because the function is called only once. • The algorithm has a complexity of O(1) because it does not depend on n. • No matter how big the problem becomes, the space complexity remains the same since the same variables are used, and the function is called only once.
  • 34. Time Complexity of an Algorithm long fact (long x) { if (x<=1) return(1); else return (x * fact(x-1)); } • Data space : x • Environment Space: fact() is called recursively , and so the amount of space this program used is based on the size of the problem.
  • 35. Measure Algorithms’ Performance • It needs programs to create ,append, update the database, print data, permit online enquiry and so on. • A Programmer should identify all requirements to solve the problem like:- – Type of Programming language – Narration of the program describing the tasks to be performed – Frequency of Processing (hourly, daily, weekly etc) – Input and output of the program – Limitations and restrictions for the program
  • 36. Measure Algorithms’ Performance • What metric should be used to judge algorithms? – Length of the program (lines of code) – Ease of programming (bugs, maintenance) – Memory required – Running time *Running time is the dominant standard. – Quantifiable and easy to compare – Often the critical bottleneck
  • 37. CONTACT ME AT: Akhil Kaushik akhilkaushik05@gmail.com 9416910303 CONTACT ME AT: Akhil Kaushik akhilkaushik05@gmail.com 9416910303 Thank You !!!