SlideShare a Scribd company logo
1 of 14
DAA UNIT 3
BY:SURBHI SAROHA
SYLLABUS
 Pattern matching
 Matrix multiplication
 Graph algorithm
 Algebraic problem
 NP Hard and NP complete problem
Pattern matching
 Pattern matching in computer science is the checking and locating of specific
sequences of data of some pattern among raw data or a sequence of tokens.
 Unlike pattern recognition, the match has to be exact in the case of pattern
matching.
 Pattern matching is one of the most fundamental and important paradigms in
several programming languages.
 Many applications make use of pattern matching as a major part of their
tasks.
Cont….
 Pattern matching, in its classical form, involves the use of one-dimensional
string matching.
 Patterns are either tree structures or sequences. There are different classes
of programming languages and machines which make use of pattern matching.
 In the case of machines, the major classifications include deterministic finite
state automata, deterministic pushdown automata, nondeterministic
pushdown automata and Turing machines.
 Regular programming languages make use of regular expressions for pattern
matching.
 Tree patterns are also used in certain programming languages like Haskell as a
tool to process data based on the structure. Compared to regular expressions,
tree patterns lack simplicity and efficiency.
Cont…
 There are many applications for pattern matching in computer science. High-
level language compilers make use of pattern matching in order to parse
source files to determine if they are syntactically correct.
 In programming languages and applications, pattern matching is used in
identifying the matching pattern or substituting the matching pattern with
another token sequence.
Matrix multiplication
 Given a sequence of matrices, find the most efficient way to multiply these
matrices together.
 The problem is not actually to perform the multiplications, but merely to
decide in which order to perform the multiplications.
 We have many options to multiply a chain of matrices because matrix
multiplication is associative.
 In other words, no matter how we parenthesize the product, the result will be
the same. For example, if we had four matrices A, B, C, and D, we would
have:
 (ABC)D = (AB)(CD) = A(BCD) = ....
Cont….
 However, the order in which we parenthesize the product affects the number
of simple arithmetic operations needed to compute the product, or the
efficiency.
 For example, suppose A is a 10 × 30 matrix, B is a 30 × 5 matrix, and C is a 5 ×
60 matrix. Then,
 (AB)C = (10×30×5) + (10×5×60) = 1500 + 3000 = 4500 operations
 A(BC) = (30×5×60) + (10×30×60) = 9000 + 18000 = 27000 operations.
 Clearly the first parenthesization requires less number of operations.
 Given an array p[] which represents the chain of matrices such that the ith
matrix Ai is of dimension p[i-1] x p[i].
 We need to write a function MatrixChainOrder() that should return the
minimum number of multiplications needed to multiply the chain.
Graph algorithm
 A graph is an abstract notation used to represent the connection between
pairs of objects. A graph consists of −
 Vertices − Interconnected objects in a graph are called vertices. Vertices are
also known as nodes.
 Edges − Edges are the links that connect the vertices.
 There are two types of graphs −
 Directed graph − In a directed graph, edges have direction, i.e., edges go
from one vertex to another.
 Undirected graph − In an undirected graph, edges have no direction.
 https://www.tutorialspoint.com/parallel_algorithm/graph_algorithm.htm
Algebraic problem
 The following is a list of several popular design approaches:
 1. Divide and Conquer Approach: It is a top-down approach. The algorithms
which follow the divide & conquer techniques involve three steps:
 Divide the original problem into a set of subproblems.
 Solve every subproblem individually, recursively.
 Combine the solution of the subproblems (top level) into a solution of the
whole original problem.
Cont…
 2. Greedy Technique: Greedy method is used to solve the optimization
problem. An optimization problem is one in which we are given a set of input
values, which are required either to be maximized or minimized (known as
objective), i.e. some constraints or conditions.
 Greedy Algorithm always makes the choice (greedy criteria) looks best at the
moment, to optimize a given objective.
 The greedy algorithm doesn't always guarantee the optimal solution however
it generally produces a solution that is very close in value to the optimal.
 3. Dynamic Programming: Dynamic Programming is a bottom-up approach we
solve all possible small problems and then combine them to obtain solutions
for bigger problems.
Cont…
 This is particularly helpful when the number of copying subproblems is
exponentially large. Dynamic Programming is frequently related
to Optimization Problems.
 4. Branch and Bound: In Branch & Bound algorithm a given subproblem,
which cannot be bounded, has to be divided into at least two new restricted
subproblems. Branch and Bound algorithm are methods for global
optimization in non-convex problems. Branch and Bound algorithms can be
slow, however in the worst case they require effort that grows exponentially
with problem size, but in some cases we are lucky, and the method coverage
with much less effort.
 5. Randomized Algorithms: A randomized algorithm is defined as an
algorithm that is allowed to access a source of independent, unbiased random
bits, and it is then allowed to use these random bits to influence its
computation.
Cont…
 6. Backtracking Algorithm: Backtracking Algorithm tries each possibility until
they find the right one. It is a depth-first search of the set of possible
solution. During the search, if an alternative doesn't work, then backtrack to
the choice point, the place which presented different alternatives, and tries
the next alternative.
 7. Randomized Algorithm: A randomized algorithm uses a random number at
least once during the computation make a decision.
 Example 1: In Quick Sort, using a random number to choose a pivot.
NP Hard and NP complete problem
 NP Problem:
The NP problems set of problems whose solutions are hard to find but easy to
verify and are solved by Non-Deterministic Machine in polynomial time.
 NP-Hard Problem:
A Problem X is NP-Hard if there is an NP-Complete problem Y, such that Y is
reducible to X in polynomial time. NP-Hard problems are as hard as NP-
Complete problems. NP-Hard Problem need not be in NP class.
 NP-Complete Problem:
 A problem X is NP-Complete if there is an NP problem Y, such that Y is
reducible to X in polynomial time. NP-Complete problems are as hard as NP
problems. A problem is NP-Complete if it is a part of both NP and NP-Hard
Problem. A non-deterministic Turing machine can solve NP-Complete problem
in polynomial time.
Thank you
 https://www.geeksforgeeks.org/difference-between-np-hard-and-np-
complete-problem/

More Related Content

Similar to DAA UNIT 3

Essentials of machine learning algorithms
Essentials of machine learning algorithmsEssentials of machine learning algorithms
Essentials of machine learning algorithmsArunangsu Sahu
 
CubeIT Tech - Algorithms
CubeIT Tech - AlgorithmsCubeIT Tech - Algorithms
CubeIT Tech - AlgorithmsKirill Suslov
 
Kk20503 1 introduction
Kk20503 1 introductionKk20503 1 introduction
Kk20503 1 introductionLow Ying Hao
 
Discrete structure ch 3 short question's
Discrete structure ch 3 short question'sDiscrete structure ch 3 short question's
Discrete structure ch 3 short question'shammad463061
 
Aad introduction
Aad introductionAad introduction
Aad introductionMr SMAK
 
Ic lecture6 architecture and algo
Ic lecture6 architecture and algoIc lecture6 architecture and algo
Ic lecture6 architecture and algoAttaullahRahimoon
 
Architecture Algorithm Definition
Architecture Algorithm DefinitionArchitecture Algorithm Definition
Architecture Algorithm DefinitionGaditek
 
Machine learning interview questions and answers
Machine learning interview questions and answersMachine learning interview questions and answers
Machine learning interview questions and answerskavinilavuG
 
Supervised and unsupervised learning
Supervised and unsupervised learningSupervised and unsupervised learning
Supervised and unsupervised learningAmAn Singh
 
CH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxCH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxsatvikkushwaha1
 
A tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbiesA tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbiesVimal Gupta
 

Similar to DAA UNIT 3 (20)

chapter 1
chapter 1chapter 1
chapter 1
 
Essentials of machine learning algorithms
Essentials of machine learning algorithmsEssentials of machine learning algorithms
Essentials of machine learning algorithms
 
CubeIT Tech - Algorithms
CubeIT Tech - AlgorithmsCubeIT Tech - Algorithms
CubeIT Tech - Algorithms
 
supervised.pptx
supervised.pptxsupervised.pptx
supervised.pptx
 
Mscs discussion
Mscs discussionMscs discussion
Mscs discussion
 
Kk20503 1 introduction
Kk20503 1 introductionKk20503 1 introduction
Kk20503 1 introduction
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Discrete structure ch 3 short question's
Discrete structure ch 3 short question'sDiscrete structure ch 3 short question's
Discrete structure ch 3 short question's
 
Aad introduction
Aad introductionAad introduction
Aad introduction
 
Ic lecture6 architecture and algo
Ic lecture6 architecture and algoIc lecture6 architecture and algo
Ic lecture6 architecture and algo
 
Architecture Algorithm Definition
Architecture Algorithm DefinitionArchitecture Algorithm Definition
Architecture Algorithm Definition
 
Machine learning interview questions and answers
Machine learning interview questions and answersMachine learning interview questions and answers
Machine learning interview questions and answers
 
Algoritmos
AlgoritmosAlgoritmos
Algoritmos
 
Supervised and unsupervised learning
Supervised and unsupervised learningSupervised and unsupervised learning
Supervised and unsupervised learning
 
Daa chapter 1
Daa chapter 1Daa chapter 1
Daa chapter 1
 
CH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxCH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptx
 
ML Lec 1 (1).pptx
ML Lec 1 (1).pptxML Lec 1 (1).pptx
ML Lec 1 (1).pptx
 
A tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbiesA tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbies
 
mmmmmmm
mmmmmmmmmmmmmm
mmmmmmm
 
Explore ml day 2
Explore ml day 2Explore ml day 2
Explore ml day 2
 

More from SURBHI SAROHA

Cloud Computing (Infrastructure as a Service)UNIT 2
Cloud Computing (Infrastructure as a Service)UNIT 2Cloud Computing (Infrastructure as a Service)UNIT 2
Cloud Computing (Infrastructure as a Service)UNIT 2SURBHI SAROHA
 
Management Information System(Unit 2).pptx
Management Information System(Unit 2).pptxManagement Information System(Unit 2).pptx
Management Information System(Unit 2).pptxSURBHI SAROHA
 
Searching in Data Structure(Linear search and Binary search)
Searching in Data Structure(Linear search and Binary search)Searching in Data Structure(Linear search and Binary search)
Searching in Data Structure(Linear search and Binary search)SURBHI SAROHA
 
Management Information System(UNIT 1).pptx
Management Information System(UNIT 1).pptxManagement Information System(UNIT 1).pptx
Management Information System(UNIT 1).pptxSURBHI SAROHA
 
Introduction to Cloud Computing(UNIT 1).pptx
Introduction to Cloud Computing(UNIT 1).pptxIntroduction to Cloud Computing(UNIT 1).pptx
Introduction to Cloud Computing(UNIT 1).pptxSURBHI SAROHA
 
Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)SURBHI SAROHA
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)SURBHI SAROHA
 
Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1SURBHI SAROHA
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)SURBHI SAROHA
 

More from SURBHI SAROHA (20)

Cloud Computing (Infrastructure as a Service)UNIT 2
Cloud Computing (Infrastructure as a Service)UNIT 2Cloud Computing (Infrastructure as a Service)UNIT 2
Cloud Computing (Infrastructure as a Service)UNIT 2
 
Management Information System(Unit 2).pptx
Management Information System(Unit 2).pptxManagement Information System(Unit 2).pptx
Management Information System(Unit 2).pptx
 
Searching in Data Structure(Linear search and Binary search)
Searching in Data Structure(Linear search and Binary search)Searching in Data Structure(Linear search and Binary search)
Searching in Data Structure(Linear search and Binary search)
 
Management Information System(UNIT 1).pptx
Management Information System(UNIT 1).pptxManagement Information System(UNIT 1).pptx
Management Information System(UNIT 1).pptx
 
Introduction to Cloud Computing(UNIT 1).pptx
Introduction to Cloud Computing(UNIT 1).pptxIntroduction to Cloud Computing(UNIT 1).pptx
Introduction to Cloud Computing(UNIT 1).pptx
 
JAVA (UNIT 5)
JAVA (UNIT 5)JAVA (UNIT 5)
JAVA (UNIT 5)
 
DBMS (UNIT 5)
DBMS (UNIT 5)DBMS (UNIT 5)
DBMS (UNIT 5)
 
DBMS UNIT 4
DBMS UNIT 4DBMS UNIT 4
DBMS UNIT 4
 
JAVA(UNIT 4)
JAVA(UNIT 4)JAVA(UNIT 4)
JAVA(UNIT 4)
 
OOPs & C++(UNIT 5)
OOPs & C++(UNIT 5)OOPs & C++(UNIT 5)
OOPs & C++(UNIT 5)
 
OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)
 
DBMS UNIT 3
DBMS UNIT 3DBMS UNIT 3
DBMS UNIT 3
 
JAVA (UNIT 3)
JAVA (UNIT 3)JAVA (UNIT 3)
JAVA (UNIT 3)
 
Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)
 
DBMS (UNIT 2)
DBMS (UNIT 2)DBMS (UNIT 2)
DBMS (UNIT 2)
 
JAVA UNIT 2
JAVA UNIT 2JAVA UNIT 2
JAVA UNIT 2
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)
 
Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)
 
OOPs & C++ UNIT 3
OOPs & C++ UNIT 3OOPs & C++ UNIT 3
OOPs & C++ UNIT 3
 

Recently uploaded

MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
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
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 

Recently uploaded (20)

MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
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
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 

DAA UNIT 3

  • 2. SYLLABUS  Pattern matching  Matrix multiplication  Graph algorithm  Algebraic problem  NP Hard and NP complete problem
  • 3. Pattern matching  Pattern matching in computer science is the checking and locating of specific sequences of data of some pattern among raw data or a sequence of tokens.  Unlike pattern recognition, the match has to be exact in the case of pattern matching.  Pattern matching is one of the most fundamental and important paradigms in several programming languages.  Many applications make use of pattern matching as a major part of their tasks.
  • 4. Cont….  Pattern matching, in its classical form, involves the use of one-dimensional string matching.  Patterns are either tree structures or sequences. There are different classes of programming languages and machines which make use of pattern matching.  In the case of machines, the major classifications include deterministic finite state automata, deterministic pushdown automata, nondeterministic pushdown automata and Turing machines.  Regular programming languages make use of regular expressions for pattern matching.  Tree patterns are also used in certain programming languages like Haskell as a tool to process data based on the structure. Compared to regular expressions, tree patterns lack simplicity and efficiency.
  • 5. Cont…  There are many applications for pattern matching in computer science. High- level language compilers make use of pattern matching in order to parse source files to determine if they are syntactically correct.  In programming languages and applications, pattern matching is used in identifying the matching pattern or substituting the matching pattern with another token sequence.
  • 6. Matrix multiplication  Given a sequence of matrices, find the most efficient way to multiply these matrices together.  The problem is not actually to perform the multiplications, but merely to decide in which order to perform the multiplications.  We have many options to multiply a chain of matrices because matrix multiplication is associative.  In other words, no matter how we parenthesize the product, the result will be the same. For example, if we had four matrices A, B, C, and D, we would have:  (ABC)D = (AB)(CD) = A(BCD) = ....
  • 7. Cont….  However, the order in which we parenthesize the product affects the number of simple arithmetic operations needed to compute the product, or the efficiency.  For example, suppose A is a 10 × 30 matrix, B is a 30 × 5 matrix, and C is a 5 × 60 matrix. Then,  (AB)C = (10×30×5) + (10×5×60) = 1500 + 3000 = 4500 operations  A(BC) = (30×5×60) + (10×30×60) = 9000 + 18000 = 27000 operations.  Clearly the first parenthesization requires less number of operations.  Given an array p[] which represents the chain of matrices such that the ith matrix Ai is of dimension p[i-1] x p[i].  We need to write a function MatrixChainOrder() that should return the minimum number of multiplications needed to multiply the chain.
  • 8. Graph algorithm  A graph is an abstract notation used to represent the connection between pairs of objects. A graph consists of −  Vertices − Interconnected objects in a graph are called vertices. Vertices are also known as nodes.  Edges − Edges are the links that connect the vertices.  There are two types of graphs −  Directed graph − In a directed graph, edges have direction, i.e., edges go from one vertex to another.  Undirected graph − In an undirected graph, edges have no direction.  https://www.tutorialspoint.com/parallel_algorithm/graph_algorithm.htm
  • 9. Algebraic problem  The following is a list of several popular design approaches:  1. Divide and Conquer Approach: It is a top-down approach. The algorithms which follow the divide & conquer techniques involve three steps:  Divide the original problem into a set of subproblems.  Solve every subproblem individually, recursively.  Combine the solution of the subproblems (top level) into a solution of the whole original problem.
  • 10. Cont…  2. Greedy Technique: Greedy method is used to solve the optimization problem. An optimization problem is one in which we are given a set of input values, which are required either to be maximized or minimized (known as objective), i.e. some constraints or conditions.  Greedy Algorithm always makes the choice (greedy criteria) looks best at the moment, to optimize a given objective.  The greedy algorithm doesn't always guarantee the optimal solution however it generally produces a solution that is very close in value to the optimal.  3. Dynamic Programming: Dynamic Programming is a bottom-up approach we solve all possible small problems and then combine them to obtain solutions for bigger problems.
  • 11. Cont…  This is particularly helpful when the number of copying subproblems is exponentially large. Dynamic Programming is frequently related to Optimization Problems.  4. Branch and Bound: In Branch & Bound algorithm a given subproblem, which cannot be bounded, has to be divided into at least two new restricted subproblems. Branch and Bound algorithm are methods for global optimization in non-convex problems. Branch and Bound algorithms can be slow, however in the worst case they require effort that grows exponentially with problem size, but in some cases we are lucky, and the method coverage with much less effort.  5. Randomized Algorithms: A randomized algorithm is defined as an algorithm that is allowed to access a source of independent, unbiased random bits, and it is then allowed to use these random bits to influence its computation.
  • 12. Cont…  6. Backtracking Algorithm: Backtracking Algorithm tries each possibility until they find the right one. It is a depth-first search of the set of possible solution. During the search, if an alternative doesn't work, then backtrack to the choice point, the place which presented different alternatives, and tries the next alternative.  7. Randomized Algorithm: A randomized algorithm uses a random number at least once during the computation make a decision.  Example 1: In Quick Sort, using a random number to choose a pivot.
  • 13. NP Hard and NP complete problem  NP Problem: The NP problems set of problems whose solutions are hard to find but easy to verify and are solved by Non-Deterministic Machine in polynomial time.  NP-Hard Problem: A Problem X is NP-Hard if there is an NP-Complete problem Y, such that Y is reducible to X in polynomial time. NP-Hard problems are as hard as NP- Complete problems. NP-Hard Problem need not be in NP class.  NP-Complete Problem:  A problem X is NP-Complete if there is an NP problem Y, such that Y is reducible to X in polynomial time. NP-Complete problems are as hard as NP problems. A problem is NP-Complete if it is a part of both NP and NP-Hard Problem. A non-deterministic Turing machine can solve NP-Complete problem in polynomial time.