SlideShare a Scribd company logo
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
1
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
2
 After completing this chapter, the reader will be able to
understand the following:

 Basic tools needed to develop and analyze algorithms
 Methods to compute the efficiency of algorithms
 Ways to make a wise choice among many solutions for a
given problem
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
3
Algorithm Analysis
Asymptoti c Notations (W, p, O)
Big Omega (W)
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
4
Algorithm Analysis
Asymptoti c Notations (W, p, O)
Big Omega (W)
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
5
 The following steps elaborate the general structure of the
divide-and-conquer strategy
 If the data size n of problem P is fundamental,
calculate the result of P(n) and go to step 4
 If the data size n of problem P is not fundamental,
divide the problem P(n) into equivalent subproblems
P(n1), P(n2), … P(ni) such that i ≥ 1
 Apply divide-and-conquer recursively to each
individual subproblem P(n1), P(n2), …,P(ni)
 Combine the results of all subproblems P(n1), P(n2),…,
P(ni) to get the final solution of P(n)
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
6
 At level one, only one call to a partition is made
with n elements; at level two, Atmost two calls are
made with elements (n - 1), and so on
C(n) = O(n2)
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
7
 General
 Knapsack Problem
 Elements of Greedy Strategy
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
8
 To decide whether a problem can be solved using a
greedy strategy, the following elements should be
considered:
 Greedy-choice property
 Optimal substructure Greedy Method
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
9
 Greedy-choice property A problem exhibits
greedy-choice property if a globally optimal
solution can be arrived at by making a locally
optimal greedy choice
 That is, we make the choice that seems best at
that time without considering the results from
the sub problems
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
10
 The General Method
 Elements of Dynamic Programming
 Principle of Optimality
 Limitations of Dynamic Programming
 Knapsack Problem
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
11
 The General Method
 Elements of Dynamic Programming
 Principle of Optimality
 Limitations of Dynamic Programming
 Knapsack Problem
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
12
A dynamic programming solution has the following three
components:
 Formulate the answer as a recurrence relation or a
recursive algorithm
 Show that the number of different instances of your
recurrence is bounded by a polynomial
 Specify an order of evaluation for the recurrence
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
13
To decide whether a problem can be solved using the dynamic
programming method, the following three elements of dynamic
programming should be considered:

 Optimal substructure
 Overlapping subproblems
 Memorization
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
14
 A problem exhibits optimal substructure if an optimal
solution to the problem contains within it optimal
solutions to subproblems
 It also means that dynamic programming (and greedy
method) might apply
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
15
 When a recursive algorithm revisits the same problem
repeatedly, it is said that the optimization problem has
overlapping sub problems
 This is beneficial for dynamic programming
 It solves each subproblem once and stores the answer in a
table
 This answer can be searched in constant time when required.
This is contradictory to the divide-and-conquer strategy
where a new problem is generated at each step of recursion
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
16
 A problem exhibits optimal substructure if an optimal
solution to the problem contains within it optimal solutions
to subproblems
 It also means that dynamic programming (and greedy
method) might apply
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
17
 However, it uses the control structure similar to the
recursive algorithm
 In a memorized recursive algorithm, an entry is
maintained in a table for the solution to each subproblem
 Initially, all entries contain a special value, which
indicates that the entry is not yet used
 For each subproblem, which is encountered for the first
time, its solution is computed and stored in the table
 Next time, for that subproblem, its entry is searched and
the value is used
 This can be implemented using hashing
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
18
 The principle of optimality states that an optimal
sequence of decisions has the property that whatever
the initial state and decision are, the remaining
decisions must constitute an optimal decision
sequence with regard to the state resulting from the
first decision
Principle of Optimality
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
19
 Pattern matching is the process of finding the
presence of a particular string (pattern) in the given
string (text)
Pattern Matching
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
20
 Database search
 Search engine
 Text editors
 Intrusion detection
 Natural language processing
 Feature detection in digitized images
A few such applications are as follows:
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
21
The most popular are the following:
Brute-force approach
Boyer–Moore algorithm
Knuth–Morris–Pratt algorithm
Robin–Karp algorithm
Text partitioning algorithm
Semi-numerical algorithm
Popular techniques for
string pattern search
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
22
 String : A string is a finite sequence of symbols that are
chosen from a set or alphabet:
 Alphabet is a set of characters or symbols
 Substring: A substring or subsequence of a string is a
subset of the symbols in a string where the order of
elements is preserved
 Suffix: A suffix of S is a substring S[i, …, m − 1], where i
ranges between 0 and m − 1
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
23
 This is a simple straight forward approach based on
the comparison of a pattern character by character
with a string
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
24
 The steps involved in this approach are as
follows:
 Adjust the pattern P at beginning of the text
 Start moving from left to right and compare the
character of pattern to the corresponding character
in text
 Continue with step 2 until successful (all characters
of the pattern are matched) or unsuccessful (a
mismatch is detected)
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
25
 Boyer and Moore have developed an efficient pattern
matching algorithm
 Instead of sliding by one character to the right at a time, in
Boyer–Moore approach, the sliding to the right is done in
longer steps
 The algorithm scans the character of pattern from right to
left beginning with the rightmost character
 If the text symbol compared with the rightmost
pattern symbol does not occur in the pattern at all, then the
pattern can be shifted by m positions (where m is length
of pattern)
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
26
 The researchers Knuth, Morris, and Pattern
proposed a linear time algorithm for the string
matching problem
 In this approach, a matching time of O(n) is
achieved by avoiding comparisons with characters
of T that have previously been involved in
comparison with some element of the pattern P to
be matched so that backtracking is avoided
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
27
 The KMP matcher finds the occurrence of the
pattern P in text T and returns the number of shifts
of P, after which the occurrence is found taking T, P,
and prefix function p as inputs
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
28
 A compact data structure that represents a set of
strings (such as all the words in a text) known as tries
 A trie is a tree-based data structure for storing strings
to make pattern matching faster
 A trie helps in pattern matching in time that is
proportional to the length of the pattern
 Tries can be used to perform prefix query for
information retrieval
 Prefix query searches for the longest prefix of a given
string that matches a prefix of some string in the tries
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
29
 There are variants of tries, which are listed as
follows:
 Standard tries
 Compressed trie
 Suffix tries
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
30
 The standard trie for a set of strings S is an ordered tree
such that
 Each node but the root is labelled with a character;
 The children of a node are alphabetically ordered;
 The paths from the external nodes to the oot yield the
strings of S
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
31
 Similar to the standard trie, a compressed is a tree-
based data structure
 For storing strings in order to make pattern matching
much faster
 This is an optimized approach for pattern matching
specially suitable for applications where time is a
more crucial factor
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
32
Following are the unique characteristics of
compressed tire:
 A compressed trie (or Patricia trie) has internal
nodes of degree at least 2
 It is obtained from standard trie by compressing
chains of redundant nodes
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
33
b
id u
o
ok il sh y
s
ell to
ck p
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
34
m e g h a v i n d
0 1 2 3 4 5 6 7 8
d e me
ghavind
nd
ndghavind
nd
ghavind
vind
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
35
 A suffix trie is a compressed Trie for all the suffixes
of a text
 This is a compressed Trie, and hence, possesses all
features a compressed trie and makes it more
powerful for making a search faster as it includes
all suffixes of a text
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
36

More Related Content

What's hot

4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patil12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
14. Files - Data Structures using C++ by Varsha Patil
14. Files - Data Structures using C++ by Varsha Patil14. Files - Data Structures using C++ by Varsha Patil
14. Files - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
widespreadpromotion
 
Data Structure
Data StructureData Structure
Data Structuresheraz1
 
Stacks in algorithems & data structure
Stacks in algorithems & data structureStacks in algorithems & data structure
Stacks in algorithems & data structure
faran nawaz
 
Data Structures and Algorithm - Week 4 - Trees, Binary Trees
Data Structures and Algorithm - Week 4 - Trees, Binary TreesData Structures and Algorithm - Week 4 - Trees, Binary Trees
Data Structures and Algorithm - Week 4 - Trees, Binary Trees
Ferdin Joe John Joseph PhD
 
Week 2 - Data Structures and Algorithms
Week 2 - Data Structures and AlgorithmsWeek 2 - Data Structures and Algorithms
Week 2 - Data Structures and Algorithms
Ferdin Joe John Joseph PhD
 
Data Structures and Algorithm - Week 9 - Search Algorithms
Data Structures and Algorithm - Week 9 - Search AlgorithmsData Structures and Algorithm - Week 9 - Search Algorithms
Data Structures and Algorithm - Week 9 - Search Algorithms
Ferdin Joe John Joseph PhD
 
The D-basis Algorithm for Association Rules of High Confidence
The D-basis Algorithm for Association Rules of High ConfidenceThe D-basis Algorithm for Association Rules of High Confidence
The D-basis Algorithm for Association Rules of High Confidence
ITIIIndustries
 
Mapping Domain Names to Categories
Mapping Domain Names to CategoriesMapping Domain Names to Categories
Mapping Domain Names to Categories
Gene Chuang
 
Week 1 - Data Structures and Algorithms
Week 1 - Data Structures and AlgorithmsWeek 1 - Data Structures and Algorithms
Week 1 - Data Structures and Algorithms
Ferdin Joe John Joseph PhD
 
Data Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm AnalysisData Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm Analysis
Ferdin Joe John Joseph PhD
 
Data Structures and Algorithm - Week 8 - Minimum Spanning Trees
Data Structures and Algorithm - Week 8 - Minimum Spanning TreesData Structures and Algorithm - Week 8 - Minimum Spanning Trees
Data Structures and Algorithm - Week 8 - Minimum Spanning Trees
Ferdin Joe John Joseph PhD
 
Datastructures using c++
Datastructures using c++Datastructures using c++
Datastructures using c++
Gopi Nath
 
Data structure-question-bank
Data structure-question-bankData structure-question-bank
Data structure-question-bank
Jagan Mohan Bishoyi
 

What's hot (20)

4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil
 
12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patil12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patil
 
14. Files - Data Structures using C++ by Varsha Patil
14. Files - Data Structures using C++ by Varsha Patil14. Files - Data Structures using C++ by Varsha Patil
14. Files - Data Structures using C++ by Varsha Patil
 
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
 
15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil
 
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
 
Data Structure
Data StructureData Structure
Data Structure
 
Stacks in algorithems & data structure
Stacks in algorithems & data structureStacks in algorithems & data structure
Stacks in algorithems & data structure
 
Data Structures and Algorithm - Week 4 - Trees, Binary Trees
Data Structures and Algorithm - Week 4 - Trees, Binary TreesData Structures and Algorithm - Week 4 - Trees, Binary Trees
Data Structures and Algorithm - Week 4 - Trees, Binary Trees
 
Lecture-05-DSA
Lecture-05-DSALecture-05-DSA
Lecture-05-DSA
 
Week 2 - Data Structures and Algorithms
Week 2 - Data Structures and AlgorithmsWeek 2 - Data Structures and Algorithms
Week 2 - Data Structures and Algorithms
 
Data Structures and Algorithm - Week 9 - Search Algorithms
Data Structures and Algorithm - Week 9 - Search AlgorithmsData Structures and Algorithm - Week 9 - Search Algorithms
Data Structures and Algorithm - Week 9 - Search Algorithms
 
List moderate
List   moderateList   moderate
List moderate
 
The D-basis Algorithm for Association Rules of High Confidence
The D-basis Algorithm for Association Rules of High ConfidenceThe D-basis Algorithm for Association Rules of High Confidence
The D-basis Algorithm for Association Rules of High Confidence
 
Mapping Domain Names to Categories
Mapping Domain Names to CategoriesMapping Domain Names to Categories
Mapping Domain Names to Categories
 
Week 1 - Data Structures and Algorithms
Week 1 - Data Structures and AlgorithmsWeek 1 - Data Structures and Algorithms
Week 1 - Data Structures and Algorithms
 
Data Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm AnalysisData Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm Analysis
 
Data Structures and Algorithm - Week 8 - Minimum Spanning Trees
Data Structures and Algorithm - Week 8 - Minimum Spanning TreesData Structures and Algorithm - Week 8 - Minimum Spanning Trees
Data Structures and Algorithm - Week 8 - Minimum Spanning Trees
 
Datastructures using c++
Datastructures using c++Datastructures using c++
Datastructures using c++
 
Data structure-question-bank
Data structure-question-bankData structure-question-bank
Data structure-question-bank
 

Viewers also liked

Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. PatilDiscrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
widespreadpromotion
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
Vineeta Garg
 
5.3 dynamic programming
5.3 dynamic programming5.3 dynamic programming
5.3 dynamic programming
Krish_ver2
 
Lists, queues and stacks
Lists, queues and stacksLists, queues and stacks
Lists, queues and stacksandreeamolnar
 
Array,lists and hashes in perl
Array,lists and hashes in perlArray,lists and hashes in perl
Array,lists and hashes in perl
sana mateen
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
Vineeta Garg
 
Classes and objects1
Classes and objects1Classes and objects1
Classes and objects1
Vineeta Garg
 
Advanced data structures using c++ 3
Advanced data structures using c++ 3Advanced data structures using c++ 3
Advanced data structures using c++ 3Shaili Choudhary
 
Structured query language functions
Structured query language functionsStructured query language functions
Structured query language functions
Vineeta Garg
 
Structured query language constraints
Structured query language constraintsStructured query language constraints
Structured query language constraints
Vineeta Garg
 
Selection sort
Selection sortSelection sort
Selection sortasra khan
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
Vineeta Garg
 
Working with Cookies in NodeJS
Working with Cookies in NodeJSWorking with Cookies in NodeJS
Working with Cookies in NodeJS
Jay Dihenkar
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
Venkata.Manish Reddy
 
Quick sort
Quick sortQuick sort
Quick sort
Jehat Hassan
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Shakil Ahmed
 
Data file handling in c++
Data file handling in c++Data file handling in c++
Data file handling in c++
Vineeta Garg
 

Viewers also liked (20)

Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. PatilDiscrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
5.3 dynamic programming
5.3 dynamic programming5.3 dynamic programming
5.3 dynamic programming
 
Lists, queues and stacks
Lists, queues and stacksLists, queues and stacks
Lists, queues and stacks
 
Array,lists and hashes in perl
Array,lists and hashes in perlArray,lists and hashes in perl
Array,lists and hashes in perl
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Classes and objects1
Classes and objects1Classes and objects1
Classes and objects1
 
Advanced data structures using c++ 3
Advanced data structures using c++ 3Advanced data structures using c++ 3
Advanced data structures using c++ 3
 
Structured query language functions
Structured query language functionsStructured query language functions
Structured query language functions
 
Structured query language constraints
Structured query language constraintsStructured query language constraints
Structured query language constraints
 
Pp
PpPp
Pp
 
Selection sort
Selection sortSelection sort
Selection sort
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
Working with Cookies in NodeJS
Working with Cookies in NodeJSWorking with Cookies in NodeJS
Working with Cookies in NodeJS
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
 
C++ data types
C++ data typesC++ data types
C++ data types
 
Dynamic pgmming
Dynamic pgmmingDynamic pgmming
Dynamic pgmming
 
Quick sort
Quick sortQuick sort
Quick sort
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Data file handling in c++
Data file handling in c++Data file handling in c++
Data file handling in c++
 

Similar to 16. Algo analysis & Design - Data Structures using C++ by Varsha Patil

EE-232-LEC-01 Data_structures.pptx
EE-232-LEC-01 Data_structures.pptxEE-232-LEC-01 Data_structures.pptx
EE-232-LEC-01 Data_structures.pptx
iamultapromax
 
A Review of Constraint Programming
A Review of Constraint ProgrammingA Review of Constraint Programming
A Review of Constraint Programming
Editor IJCATR
 
Discovering Novel Information with sentence Level clustering From Multi-docu...
Discovering Novel Information with sentence Level clustering  From Multi-docu...Discovering Novel Information with sentence Level clustering  From Multi-docu...
Discovering Novel Information with sentence Level clustering From Multi-docu...
irjes
 
G04124041046
G04124041046G04124041046
G04124041046
IOSR-JEN
 
01VD062009003760042.pdf
01VD062009003760042.pdf01VD062009003760042.pdf
01VD062009003760042.pdf
SunilMatsagar1
 
Algorithm Specification and Data Abstraction
Algorithm Specification and Data Abstraction Algorithm Specification and Data Abstraction
Algorithm Specification and Data Abstraction
Ashutosh Satapathy
 
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
Dr Arash Najmaei ( Phd., MBA, BSc)
 
Regression with Microsoft Azure & Ms Excel
Regression with Microsoft Azure & Ms ExcelRegression with Microsoft Azure & Ms Excel
Regression with Microsoft Azure & Ms Excel
Dr. Abdul Ahad Abro
 
Semantic Annotation of Documents
Semantic Annotation of DocumentsSemantic Annotation of Documents
Semantic Annotation of Documents
subash chandra
 
Cuckoo Search: Recent Advances and Applications
Cuckoo Search: Recent Advances and ApplicationsCuckoo Search: Recent Advances and Applications
Cuckoo Search: Recent Advances and Applications
Xin-She Yang
 
Algorithm of Dynamic Programming for Paper-Reviewer Assignment Problem
Algorithm of Dynamic Programming for Paper-Reviewer Assignment ProblemAlgorithm of Dynamic Programming for Paper-Reviewer Assignment Problem
Algorithm of Dynamic Programming for Paper-Reviewer Assignment Problem
IRJET Journal
 
A Fairness-aware Machine Learning Interface for End-to-end Discrimination Dis...
A Fairness-aware Machine Learning Interface for End-to-end Discrimination Dis...A Fairness-aware Machine Learning Interface for End-to-end Discrimination Dis...
A Fairness-aware Machine Learning Interface for End-to-end Discrimination Dis...
wajrcs
 
Experiments on Design Pattern Discovery
Experiments on Design Pattern DiscoveryExperiments on Design Pattern Discovery
Experiments on Design Pattern Discovery
Tim Menzies
 
Sample prac exam2013
Sample prac exam2013Sample prac exam2013
Sample prac exam2013hccit
 
Analyzing the solutions of DEA through information visualization and data min...
Analyzing the solutions of DEA through information visualization and data min...Analyzing the solutions of DEA through information visualization and data min...
Analyzing the solutions of DEA through information visualization and data min...
Gurdal Ertek
 
LNCS 5050 - Bilevel Optimization and Machine Learning
LNCS 5050 - Bilevel Optimization and Machine LearningLNCS 5050 - Bilevel Optimization and Machine Learning
LNCS 5050 - Bilevel Optimization and Machine Learningbutest
 
EXPERT OPINION AND COHERENCE BASED TOPIC MODELING
EXPERT OPINION AND COHERENCE BASED TOPIC MODELINGEXPERT OPINION AND COHERENCE BASED TOPIC MODELING
EXPERT OPINION AND COHERENCE BASED TOPIC MODELING
ijnlc
 

Similar to 16. Algo analysis & Design - Data Structures using C++ by Varsha Patil (20)

EE-232-LEC-01 Data_structures.pptx
EE-232-LEC-01 Data_structures.pptxEE-232-LEC-01 Data_structures.pptx
EE-232-LEC-01 Data_structures.pptx
 
OR Slide
OR SlideOR Slide
OR Slide
 
A Review of Constraint Programming
A Review of Constraint ProgrammingA Review of Constraint Programming
A Review of Constraint Programming
 
Discovering Novel Information with sentence Level clustering From Multi-docu...
Discovering Novel Information with sentence Level clustering  From Multi-docu...Discovering Novel Information with sentence Level clustering  From Multi-docu...
Discovering Novel Information with sentence Level clustering From Multi-docu...
 
G04124041046
G04124041046G04124041046
G04124041046
 
01VD062009003760042.pdf
01VD062009003760042.pdf01VD062009003760042.pdf
01VD062009003760042.pdf
 
Algorithm Specification and Data Abstraction
Algorithm Specification and Data Abstraction Algorithm Specification and Data Abstraction
Algorithm Specification and Data Abstraction
 
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
 
Regression with Microsoft Azure & Ms Excel
Regression with Microsoft Azure & Ms ExcelRegression with Microsoft Azure & Ms Excel
Regression with Microsoft Azure & Ms Excel
 
Semantic Annotation of Documents
Semantic Annotation of DocumentsSemantic Annotation of Documents
Semantic Annotation of Documents
 
Cuckoo Search: Recent Advances and Applications
Cuckoo Search: Recent Advances and ApplicationsCuckoo Search: Recent Advances and Applications
Cuckoo Search: Recent Advances and Applications
 
Ankit presentation
Ankit presentationAnkit presentation
Ankit presentation
 
Algorithm of Dynamic Programming for Paper-Reviewer Assignment Problem
Algorithm of Dynamic Programming for Paper-Reviewer Assignment ProblemAlgorithm of Dynamic Programming for Paper-Reviewer Assignment Problem
Algorithm of Dynamic Programming for Paper-Reviewer Assignment Problem
 
A Fairness-aware Machine Learning Interface for End-to-end Discrimination Dis...
A Fairness-aware Machine Learning Interface for End-to-end Discrimination Dis...A Fairness-aware Machine Learning Interface for End-to-end Discrimination Dis...
A Fairness-aware Machine Learning Interface for End-to-end Discrimination Dis...
 
Experiments on Design Pattern Discovery
Experiments on Design Pattern DiscoveryExperiments on Design Pattern Discovery
Experiments on Design Pattern Discovery
 
Sample prac exam2013
Sample prac exam2013Sample prac exam2013
Sample prac exam2013
 
Analyzing the solutions of DEA through information visualization and data min...
Analyzing the solutions of DEA through information visualization and data min...Analyzing the solutions of DEA through information visualization and data min...
Analyzing the solutions of DEA through information visualization and data min...
 
Lec1
Lec1Lec1
Lec1
 
LNCS 5050 - Bilevel Optimization and Machine Learning
LNCS 5050 - Bilevel Optimization and Machine LearningLNCS 5050 - Bilevel Optimization and Machine Learning
LNCS 5050 - Bilevel Optimization and Machine Learning
 
EXPERT OPINION AND COHERENCE BASED TOPIC MODELING
EXPERT OPINION AND COHERENCE BASED TOPIC MODELINGEXPERT OPINION AND COHERENCE BASED TOPIC MODELING
EXPERT OPINION AND COHERENCE BASED TOPIC MODELING
 

Recently uploaded

Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
2023240532
 
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
pchutichetpong
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
v3tuleee
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
jerlynmaetalle
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
javier ramirez
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
mbawufebxi
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
ewymefz
 
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
u86oixdj
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
haila53
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
balafet
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
dwreak4tg
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
slg6lamcq
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
oz8q3jxlp
 
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptxData_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
AnirbanRoy608946
 

Recently uploaded (20)

Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
 
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
 
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
 
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptxData_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
 

16. Algo analysis & Design - Data Structures using C++ by Varsha Patil

  • 1. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 1
  • 2. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 2  After completing this chapter, the reader will be able to understand the following:   Basic tools needed to develop and analyze algorithms  Methods to compute the efficiency of algorithms  Ways to make a wise choice among many solutions for a given problem
  • 3. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 3 Algorithm Analysis Asymptoti c Notations (W, p, O) Big Omega (W)
  • 4. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 4 Algorithm Analysis Asymptoti c Notations (W, p, O) Big Omega (W)
  • 5. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 5  The following steps elaborate the general structure of the divide-and-conquer strategy  If the data size n of problem P is fundamental, calculate the result of P(n) and go to step 4  If the data size n of problem P is not fundamental, divide the problem P(n) into equivalent subproblems P(n1), P(n2), … P(ni) such that i ≥ 1  Apply divide-and-conquer recursively to each individual subproblem P(n1), P(n2), …,P(ni)  Combine the results of all subproblems P(n1), P(n2),…, P(ni) to get the final solution of P(n)
  • 6. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 6  At level one, only one call to a partition is made with n elements; at level two, Atmost two calls are made with elements (n - 1), and so on C(n) = O(n2)
  • 7. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 7  General  Knapsack Problem  Elements of Greedy Strategy
  • 8. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 8  To decide whether a problem can be solved using a greedy strategy, the following elements should be considered:  Greedy-choice property  Optimal substructure Greedy Method
  • 9. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 9  Greedy-choice property A problem exhibits greedy-choice property if a globally optimal solution can be arrived at by making a locally optimal greedy choice  That is, we make the choice that seems best at that time without considering the results from the sub problems
  • 10. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 10  The General Method  Elements of Dynamic Programming  Principle of Optimality  Limitations of Dynamic Programming  Knapsack Problem
  • 11. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 11  The General Method  Elements of Dynamic Programming  Principle of Optimality  Limitations of Dynamic Programming  Knapsack Problem
  • 12. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 12 A dynamic programming solution has the following three components:  Formulate the answer as a recurrence relation or a recursive algorithm  Show that the number of different instances of your recurrence is bounded by a polynomial  Specify an order of evaluation for the recurrence
  • 13. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 13 To decide whether a problem can be solved using the dynamic programming method, the following three elements of dynamic programming should be considered:   Optimal substructure  Overlapping subproblems  Memorization
  • 14. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 14  A problem exhibits optimal substructure if an optimal solution to the problem contains within it optimal solutions to subproblems  It also means that dynamic programming (and greedy method) might apply
  • 15. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 15  When a recursive algorithm revisits the same problem repeatedly, it is said that the optimization problem has overlapping sub problems  This is beneficial for dynamic programming  It solves each subproblem once and stores the answer in a table  This answer can be searched in constant time when required. This is contradictory to the divide-and-conquer strategy where a new problem is generated at each step of recursion
  • 16. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 16  A problem exhibits optimal substructure if an optimal solution to the problem contains within it optimal solutions to subproblems  It also means that dynamic programming (and greedy method) might apply
  • 17. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 17  However, it uses the control structure similar to the recursive algorithm  In a memorized recursive algorithm, an entry is maintained in a table for the solution to each subproblem  Initially, all entries contain a special value, which indicates that the entry is not yet used  For each subproblem, which is encountered for the first time, its solution is computed and stored in the table  Next time, for that subproblem, its entry is searched and the value is used  This can be implemented using hashing
  • 18. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 18  The principle of optimality states that an optimal sequence of decisions has the property that whatever the initial state and decision are, the remaining decisions must constitute an optimal decision sequence with regard to the state resulting from the first decision Principle of Optimality
  • 19. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 19  Pattern matching is the process of finding the presence of a particular string (pattern) in the given string (text) Pattern Matching
  • 20. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 20  Database search  Search engine  Text editors  Intrusion detection  Natural language processing  Feature detection in digitized images A few such applications are as follows:
  • 21. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 21 The most popular are the following: Brute-force approach Boyer–Moore algorithm Knuth–Morris–Pratt algorithm Robin–Karp algorithm Text partitioning algorithm Semi-numerical algorithm Popular techniques for string pattern search
  • 22. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 22  String : A string is a finite sequence of symbols that are chosen from a set or alphabet:  Alphabet is a set of characters or symbols  Substring: A substring or subsequence of a string is a subset of the symbols in a string where the order of elements is preserved  Suffix: A suffix of S is a substring S[i, …, m − 1], where i ranges between 0 and m − 1
  • 23. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 23  This is a simple straight forward approach based on the comparison of a pattern character by character with a string
  • 24. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 24  The steps involved in this approach are as follows:  Adjust the pattern P at beginning of the text  Start moving from left to right and compare the character of pattern to the corresponding character in text  Continue with step 2 until successful (all characters of the pattern are matched) or unsuccessful (a mismatch is detected)
  • 25. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 25  Boyer and Moore have developed an efficient pattern matching algorithm  Instead of sliding by one character to the right at a time, in Boyer–Moore approach, the sliding to the right is done in longer steps  The algorithm scans the character of pattern from right to left beginning with the rightmost character  If the text symbol compared with the rightmost pattern symbol does not occur in the pattern at all, then the pattern can be shifted by m positions (where m is length of pattern)
  • 26. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 26  The researchers Knuth, Morris, and Pattern proposed a linear time algorithm for the string matching problem  In this approach, a matching time of O(n) is achieved by avoiding comparisons with characters of T that have previously been involved in comparison with some element of the pattern P to be matched so that backtracking is avoided
  • 27. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 27  The KMP matcher finds the occurrence of the pattern P in text T and returns the number of shifts of P, after which the occurrence is found taking T, P, and prefix function p as inputs
  • 28. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 28  A compact data structure that represents a set of strings (such as all the words in a text) known as tries  A trie is a tree-based data structure for storing strings to make pattern matching faster  A trie helps in pattern matching in time that is proportional to the length of the pattern  Tries can be used to perform prefix query for information retrieval  Prefix query searches for the longest prefix of a given string that matches a prefix of some string in the tries
  • 29. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 29  There are variants of tries, which are listed as follows:  Standard tries  Compressed trie  Suffix tries
  • 30. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 30  The standard trie for a set of strings S is an ordered tree such that  Each node but the root is labelled with a character;  The children of a node are alphabetically ordered;  The paths from the external nodes to the oot yield the strings of S
  • 31. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 31  Similar to the standard trie, a compressed is a tree- based data structure  For storing strings in order to make pattern matching much faster  This is an optimized approach for pattern matching specially suitable for applications where time is a more crucial factor
  • 32. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 32 Following are the unique characteristics of compressed tire:  A compressed trie (or Patricia trie) has internal nodes of degree at least 2  It is obtained from standard trie by compressing chains of redundant nodes
  • 33. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 33 b id u o ok il sh y s ell to ck p
  • 34. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 34 m e g h a v i n d 0 1 2 3 4 5 6 7 8 d e me ghavind nd ndghavind nd ghavind vind
  • 35. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 35  A suffix trie is a compressed Trie for all the suffixes of a text  This is a compressed Trie, and hence, possesses all features a compressed trie and makes it more powerful for making a search faster as it includes all suffixes of a text
  • 36. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 36