SlideShare a Scribd company logo
1 of 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 !!!

More Related Content

What's hot

What's hot (20)

Data structures
Data structuresData structures
Data structures
 
Searching
SearchingSearching
Searching
 
Introduction to datastructure and algorithm
Introduction to datastructure and algorithmIntroduction to datastructure and algorithm
Introduction to datastructure and algorithm
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 
Array in c++
Array in c++Array in c++
Array in c++
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Python basic
Python basicPython basic
Python basic
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
B and B+ tree
B and B+ treeB and B+ tree
B and B+ tree
 
Data structures using c
Data structures using cData structures using c
Data structures using c
 
Python strings
Python stringsPython strings
Python strings
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming language
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
Linear Search Data Structure
Linear Search Data StructureLinear Search Data Structure
Linear Search Data Structure
 
Functions and modules in python
Functions and modules in pythonFunctions and modules in python
Functions and modules in python
 
Linked list
Linked listLinked list
Linked list
 
File in C language
File in C languageFile in C language
File in C language
 

Similar to 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
 

Similar to 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
 

More from 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
 
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
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to CompilersAkhil Kaushik
 

More from 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
 
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
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
 

Recently uploaded

ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptxJonalynLegaspi2
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 

Recently uploaded (20)

ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptx
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 

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 !!!