SlideShare a Scribd company logo
1 of 14
Data Structures and Algorithms
Snehal Masne
www.TechProceed.com
www.iSnehal.com
2
learn ...
... how to design “good” algorithms and data
structures
... how to evaluate the performance of algorithms
... how to program basic algorithms and data
structures
Goals
3
learn ...
... how to solve the most common algorithmic
problems, such as
searching a data collection
sorting data
exploring a graph/network
text processing
Goals
4
Michael T. Goodrich, Roberto Tamassia:
Algorithm Design: Foundations, Analysis,
and Internet Examples.
John Wiley & Sons, Inc., 2001.
Mark Allen Weiss:
Data Structures and Algorithm Analysis
in Java.
2nd edition, Addision Wesley, 2007.
Literature
5
Thomas H. Cormen, Charles E. Leiserson,
Ronald L. Rivest, Clifford Stein:
Introduction to Algorithms.
3rd edition, The MIT Press, 2009.
Donald E. Knuth:
The Art of Computer Programming.
Vol. 1: Fundamental Algorithms.
Vol. 3: Sorting and Searching.
Addision Wesley, 1997/98.
Literature
6
• an algorithm is a step-by-step procedure for
solving a problem in a finite amount of time and
space
• an algorithm is “good” if it is correct and solves the
problem in lowest time/space known for that
problem
Algorithms
Input Algorithm Output
7
• a program is a description of an algorithm in a
programming language
• a program repesents exactly one algorithm
• an algorithm represents a multitude of programs
• writing a good program requires designing a good
algorithm
No algorithm, no program!
Programs
8
Problem – Algorithm - Program
Problem
Algorithm 1 Algorithm 2
Program 21
Program 22
. . .
. . .
. . .
. . .
. . .
9
[ 1] int mod(int a, int b) {
[ 2] /* Requirements (input): a: a>=0; b: b>0 */
[ 3] /* Guarantee (output): r: a=t*b + r and 0<r<=b */
[ 4] /* (1) Declaration */
[ 5] int r;
[ 6] /* (2) Initialization */
[ 7] r=a;
[ 8] /* (3) Iteration start */
[ 9] while (r>=b) {
[10] /* (4) Problem reduction */
[11] r=r-b;
[12] /* (5) Iteration end */
[13] }
[14] /* (6) Output formation */
[15] return(r);
[16] }
Iteration
10
[ 1] int mod(int a, int b) {
[ 2] /* Requirements (input): a: a>=0; b: b>0 */
[ 3] /* Guarantee (output): r: a=t*b + r and 0<r<=b */
[ 4] /* (1) Declaration */
[ 5] int r;
[ 6] /* (2) Initialization */
[ 7] r=a;
[ 8] /* (3) Trivial case */
[ 9] if (r<b) return(r);
[10] /* (4) Problem reduction */
[11] r=r-b;
[12] /* (5) Recursion step */
[13] return(mod(r,b));
[14] }
Recursion
11
• elementary types (in Java):
–logical type: boolean
–integer type: int, short, byte, long
–floating point type: float, double
–character type: char
• composed data types (concrete data structures):
–arrays, e.g., int[], char[]
–records/structs (not available in Java)
–lists
Data Types
12
• an abstract data type (ADT) is an abstraction of a
concrete data structure
• an ADT specifies:
–data stored (auxiliary data, inclusive)
–operations on the data
–error conditions associated with operations
• an ADT abstracts from the implementation of the
data and operations
Abstract Data Types
13
• a class is an ADT implementation in an OOPL
• an instance of an ADT (or a class) has an
operational life span, during which a state (an
element of the ADT„s data set) is always being
assigned to the object
• methods of an ADT are programs manipulating the
state of an object
• a state of an object can only be manipulated by
ADT methods (encapsulation)
Objects
14
• ADT modeling a simple stock trading system
• the data stored are buy/sell orders
• the operations supported are:
–Order buy(Stock st, Shares sh, Price p)
–Order sell(Stock st, Shares sh, Price p)
–void cancel(Order)
• error conditions are:
–buy/sell a nonexistent stock
–cancel a nonexistent order
Example of an Abstract Data Type

More Related Content

What's hot

What's hot (6)

Interviewtcs
InterviewtcsInterviewtcs
Interviewtcs
 
When to use a structure vs classes in c++
When to use a structure vs classes in c++When to use a structure vs classes in c++
When to use a structure vs classes in c++
 
Structure in c language
Structure in c languageStructure in c language
Structure in c language
 
C Structures & Unions
C Structures & UnionsC Structures & Unions
C Structures & Unions
 
C# program structure
C# program structureC# program structure
C# program structure
 
structures and unions in 'C'
structures and unions in 'C'structures and unions in 'C'
structures and unions in 'C'
 

Viewers also liked

Nutraceutical-ExecutiveSummary
Nutraceutical-ExecutiveSummaryNutraceutical-ExecutiveSummary
Nutraceutical-ExecutiveSummaryTom McNulty
 
Nunca Retes A 1 Mujer
Nunca Retes A 1 MujerNunca Retes A 1 Mujer
Nunca Retes A 1 Mujerpillaliebres
 
WhistleB study-on-corporate-whistleblowing-2016
WhistleB study-on-corporate-whistleblowing-2016WhistleB study-on-corporate-whistleblowing-2016
WhistleB study-on-corporate-whistleblowing-2016Karin Henriksson
 
Benjamin Franklin
Benjamin FranklinBenjamin Franklin
Benjamin Franklinwmsbierer
 
NetObjects Fusion 2015 Manual Book
NetObjects Fusion 2015 Manual BookNetObjects Fusion 2015 Manual Book
NetObjects Fusion 2015 Manual BookBrandon Taylor
 
Whistleblowing Presentation
Whistleblowing PresentationWhistleblowing Presentation
Whistleblowing Presentationkatlyntrzaska
 
Analisis Karya 2 Dimensi
Analisis Karya 2 DimensiAnalisis Karya 2 Dimensi
Analisis Karya 2 DimensiYoollan MW
 
Listaxe Galegos Mortos Campos Nazis
Listaxe Galegos Mortos Campos NazisListaxe Galegos Mortos Campos Nazis
Listaxe Galegos Mortos Campos NazisGZ-Israel
 
1c. Caracteristicas generales de la sintaxis del español
1c. Caracteristicas generales de la sintaxis del español1c. Caracteristicas generales de la sintaxis del español
1c. Caracteristicas generales de la sintaxis del españolvsyntact
 
Herramientas para la Transformación Digital
Herramientas para la Transformación DigitalHerramientas para la Transformación Digital
Herramientas para la Transformación DigitalIntoTheLeader
 

Viewers also liked (19)

Arbol 5
Arbol 5Arbol 5
Arbol 5
 
Nutraceutical-ExecutiveSummary
Nutraceutical-ExecutiveSummaryNutraceutical-ExecutiveSummary
Nutraceutical-ExecutiveSummary
 
Frecuencias
FrecuenciasFrecuencias
Frecuencias
 
Nunca Retes A 1 Mujer
Nunca Retes A 1 MujerNunca Retes A 1 Mujer
Nunca Retes A 1 Mujer
 
Conjugación
ConjugaciónConjugación
Conjugación
 
Ferramentas13
Ferramentas13Ferramentas13
Ferramentas13
 
WhistleB study-on-corporate-whistleblowing-2016
WhistleB study-on-corporate-whistleblowing-2016WhistleB study-on-corporate-whistleblowing-2016
WhistleB study-on-corporate-whistleblowing-2016
 
Benjamin Franklin
Benjamin FranklinBenjamin Franklin
Benjamin Franklin
 
To be influenced
To be influencedTo be influenced
To be influenced
 
Coca Cola Mentos
Coca Cola MentosCoca Cola Mentos
Coca Cola Mentos
 
2007 1st Place
2007 1st Place2007 1st Place
2007 1st Place
 
NetObjects Fusion 2015 Manual Book
NetObjects Fusion 2015 Manual BookNetObjects Fusion 2015 Manual Book
NetObjects Fusion 2015 Manual Book
 
Whistleblowing Presentation
Whistleblowing PresentationWhistleblowing Presentation
Whistleblowing Presentation
 
Spring IOC
Spring IOCSpring IOC
Spring IOC
 
Analisis Karya 2 Dimensi
Analisis Karya 2 DimensiAnalisis Karya 2 Dimensi
Analisis Karya 2 Dimensi
 
Listaxe Galegos Mortos Campos Nazis
Listaxe Galegos Mortos Campos NazisListaxe Galegos Mortos Campos Nazis
Listaxe Galegos Mortos Campos Nazis
 
English 9 - The Whistle
English 9 - The WhistleEnglish 9 - The Whistle
English 9 - The Whistle
 
1c. Caracteristicas generales de la sintaxis del español
1c. Caracteristicas generales de la sintaxis del español1c. Caracteristicas generales de la sintaxis del español
1c. Caracteristicas generales de la sintaxis del español
 
Herramientas para la Transformación Digital
Herramientas para la Transformación DigitalHerramientas para la Transformación Digital
Herramientas para la Transformación Digital
 

Similar to DSA- Learn Algorithms, Data Structures & Their Analysis

Bca2020 data structure and algorithm
Bca2020   data structure and algorithmBca2020   data structure and algorithm
Bca2020 data structure and algorithmsmumbahelp
 
Go Says WAT?
Go Says WAT?Go Says WAT?
Go Says WAT?jonbodner
 
Introduction Machine Learning Syllabus
Introduction Machine Learning SyllabusIntroduction Machine Learning Syllabus
Introduction Machine Learning SyllabusAndres Mendez-Vazquez
 
are algorithms really a black box
are algorithms really a black boxare algorithms really a black box
are algorithms really a black boxAnsgar Koene
 
Computer_Science_Sr.Sec_2021-22.pdf
Computer_Science_Sr.Sec_2021-22.pdfComputer_Science_Sr.Sec_2021-22.pdf
Computer_Science_Sr.Sec_2021-22.pdfSathyaPrabha11
 
Mapreduce Algorithms
Mapreduce AlgorithmsMapreduce Algorithms
Mapreduce AlgorithmsAmund Tveit
 
ECS (Part 1/3) - Introduction to Data-Oriented Design
ECS (Part 1/3) - Introduction to Data-Oriented DesignECS (Part 1/3) - Introduction to Data-Oriented Design
ECS (Part 1/3) - Introduction to Data-Oriented DesignPhuong Hoang Vu
 
MongoDB Project: Relational databases to Document-Oriented databases
MongoDB Project: Relational databases to Document-Oriented databasesMongoDB Project: Relational databases to Document-Oriented databases
MongoDB Project: Relational databases to Document-Oriented databasesLamprini Koutsokera
 
R Programming: Importing Data In R
R Programming: Importing Data In RR Programming: Importing Data In R
R Programming: Importing Data In RRsquared Academy
 
mongoDB Project: Relational databases & Document-Oriented databases
mongoDB Project: Relational databases & Document-Oriented databasesmongoDB Project: Relational databases & Document-Oriented databases
mongoDB Project: Relational databases & Document-Oriented databasesStratos Gounidellis
 
A Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with PythonA Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with PythonTariq Rashid
 
[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...Functional Thursday
 
Cleaner Code - CodeStock 2019 Edition
Cleaner Code - CodeStock 2019 EditionCleaner Code - CodeStock 2019 Edition
Cleaner Code - CodeStock 2019 EditionDave Fancher
 
Abir ppt3
Abir ppt3Abir ppt3
Abir ppt3abir96
 
19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm ComplexityIntro C# Book
 
Faster Interleaved Modular Multiplier Based on Sign Detection
Faster Interleaved Modular Multiplier Based on Sign DetectionFaster Interleaved Modular Multiplier Based on Sign Detection
Faster Interleaved Modular Multiplier Based on Sign DetectionVLSICS Design
 

Similar to DSA- Learn Algorithms, Data Structures & Their Analysis (20)

Bca2020 data structure and algorithm
Bca2020   data structure and algorithmBca2020   data structure and algorithm
Bca2020 data structure and algorithm
 
Go Says WAT?
Go Says WAT?Go Says WAT?
Go Says WAT?
 
Embedded C - Lecture 2
Embedded C - Lecture 2Embedded C - Lecture 2
Embedded C - Lecture 2
 
Introduction Machine Learning Syllabus
Introduction Machine Learning SyllabusIntroduction Machine Learning Syllabus
Introduction Machine Learning Syllabus
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
are algorithms really a black box
are algorithms really a black boxare algorithms really a black box
are algorithms really a black box
 
Computer_Science_Sr.Sec_2021-22.pdf
Computer_Science_Sr.Sec_2021-22.pdfComputer_Science_Sr.Sec_2021-22.pdf
Computer_Science_Sr.Sec_2021-22.pdf
 
Mapreduce Algorithms
Mapreduce AlgorithmsMapreduce Algorithms
Mapreduce Algorithms
 
ECS (Part 1/3) - Introduction to Data-Oriented Design
ECS (Part 1/3) - Introduction to Data-Oriented DesignECS (Part 1/3) - Introduction to Data-Oriented Design
ECS (Part 1/3) - Introduction to Data-Oriented Design
 
MongoDB Project: Relational databases to Document-Oriented databases
MongoDB Project: Relational databases to Document-Oriented databasesMongoDB Project: Relational databases to Document-Oriented databases
MongoDB Project: Relational databases to Document-Oriented databases
 
R Programming: Importing Data In R
R Programming: Importing Data In RR Programming: Importing Data In R
R Programming: Importing Data In R
 
mongoDB Project: Relational databases & Document-Oriented databases
mongoDB Project: Relational databases & Document-Oriented databasesmongoDB Project: Relational databases & Document-Oriented databases
mongoDB Project: Relational databases & Document-Oriented databases
 
A Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with PythonA Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with Python
 
[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...
 
arrays
arraysarrays
arrays
 
Cleaner Code - CodeStock 2019 Edition
Cleaner Code - CodeStock 2019 EditionCleaner Code - CodeStock 2019 Edition
Cleaner Code - CodeStock 2019 Edition
 
Abir ppt3
Abir ppt3Abir ppt3
Abir ppt3
 
19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity
 
Structure Arrays
Structure ArraysStructure Arrays
Structure Arrays
 
Faster Interleaved Modular Multiplier Based on Sign Detection
Faster Interleaved Modular Multiplier Based on Sign DetectionFaster Interleaved Modular Multiplier Based on Sign Detection
Faster Interleaved Modular Multiplier Based on Sign Detection
 

Recently uploaded

Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 

Recently uploaded (20)

Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 

DSA- Learn Algorithms, Data Structures & Their Analysis

  • 1. Data Structures and Algorithms Snehal Masne www.TechProceed.com www.iSnehal.com
  • 2. 2 learn ... ... how to design “good” algorithms and data structures ... how to evaluate the performance of algorithms ... how to program basic algorithms and data structures Goals
  • 3. 3 learn ... ... how to solve the most common algorithmic problems, such as searching a data collection sorting data exploring a graph/network text processing Goals
  • 4. 4 Michael T. Goodrich, Roberto Tamassia: Algorithm Design: Foundations, Analysis, and Internet Examples. John Wiley & Sons, Inc., 2001. Mark Allen Weiss: Data Structures and Algorithm Analysis in Java. 2nd edition, Addision Wesley, 2007. Literature
  • 5. 5 Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein: Introduction to Algorithms. 3rd edition, The MIT Press, 2009. Donald E. Knuth: The Art of Computer Programming. Vol. 1: Fundamental Algorithms. Vol. 3: Sorting and Searching. Addision Wesley, 1997/98. Literature
  • 6. 6 • an algorithm is a step-by-step procedure for solving a problem in a finite amount of time and space • an algorithm is “good” if it is correct and solves the problem in lowest time/space known for that problem Algorithms Input Algorithm Output
  • 7. 7 • a program is a description of an algorithm in a programming language • a program repesents exactly one algorithm • an algorithm represents a multitude of programs • writing a good program requires designing a good algorithm No algorithm, no program! Programs
  • 8. 8 Problem – Algorithm - Program Problem Algorithm 1 Algorithm 2 Program 21 Program 22 . . . . . . . . . . . . . . .
  • 9. 9 [ 1] int mod(int a, int b) { [ 2] /* Requirements (input): a: a>=0; b: b>0 */ [ 3] /* Guarantee (output): r: a=t*b + r and 0<r<=b */ [ 4] /* (1) Declaration */ [ 5] int r; [ 6] /* (2) Initialization */ [ 7] r=a; [ 8] /* (3) Iteration start */ [ 9] while (r>=b) { [10] /* (4) Problem reduction */ [11] r=r-b; [12] /* (5) Iteration end */ [13] } [14] /* (6) Output formation */ [15] return(r); [16] } Iteration
  • 10. 10 [ 1] int mod(int a, int b) { [ 2] /* Requirements (input): a: a>=0; b: b>0 */ [ 3] /* Guarantee (output): r: a=t*b + r and 0<r<=b */ [ 4] /* (1) Declaration */ [ 5] int r; [ 6] /* (2) Initialization */ [ 7] r=a; [ 8] /* (3) Trivial case */ [ 9] if (r<b) return(r); [10] /* (4) Problem reduction */ [11] r=r-b; [12] /* (5) Recursion step */ [13] return(mod(r,b)); [14] } Recursion
  • 11. 11 • elementary types (in Java): –logical type: boolean –integer type: int, short, byte, long –floating point type: float, double –character type: char • composed data types (concrete data structures): –arrays, e.g., int[], char[] –records/structs (not available in Java) –lists Data Types
  • 12. 12 • an abstract data type (ADT) is an abstraction of a concrete data structure • an ADT specifies: –data stored (auxiliary data, inclusive) –operations on the data –error conditions associated with operations • an ADT abstracts from the implementation of the data and operations Abstract Data Types
  • 13. 13 • a class is an ADT implementation in an OOPL • an instance of an ADT (or a class) has an operational life span, during which a state (an element of the ADT„s data set) is always being assigned to the object • methods of an ADT are programs manipulating the state of an object • a state of an object can only be manipulated by ADT methods (encapsulation) Objects
  • 14. 14 • ADT modeling a simple stock trading system • the data stored are buy/sell orders • the operations supported are: –Order buy(Stock st, Shares sh, Price p) –Order sell(Stock st, Shares sh, Price p) –void cancel(Order) • error conditions are: –buy/sell a nonexistent stock –cancel a nonexistent order Example of an Abstract Data Type

Editor's Notes

  1. Note: by the above definition, a “good” algorithm may still be unusable if it requires too much time/space to solve the problem (i.e. if the algorithm is intractable).