SlideShare a Scribd company logo
Fast Exact String Pattern-Matching Algorithm for
Fixed Length Patterns
Ing. Ľuboš Takáč
PhD student
Faculty of Management Science and Informatics
University of Žilina
Presentation overview
• Motivation
• Problem Definition
• Existing Solutions
• Our Implemented Algorithm
• Testing Results
• Conclusion
Motivation
• Word search game generator
• Searching string patterns with
fixed length
– M . . . E R
– . . . A H
– . . . . .
Problem Definition
• Design fast in-memory data structure (class)
• Requirements
– fast searching, if it is possible with O(1) complexity
– each founded word get only once
– each founded word must be randomly chosen
– founded word have to match the pattern
class Model
FastStringPatternSearch
+ FastStringPatternSearch(String[], Random)
+ FastStringPatternSearch(String[])
+ reset() : void
+ searchPattern(String) : String
Existing Solutions
• Relational DB table with full-text index - access to hard drive
• Linked List or array in memory – O(N) complexity
• Indexing of array – necessary to index all possible combination of
patterns to have O(1) complexity
Number of
undefined
positions
0 1 2 3 4 5 6 7 8
Example of
pattern
PATTER
NS
PATT-
RNS
PA-TE-
NS
-AT--
RNS
P-T-E--S -A--ER-- --TT---- ----E--- --------
All combinations
count 1 8 28 56 70 56 28 8 1
Total combinations
count 256
Our Implemented Algorithm
• Dynamic in-memory tree(s) with linked list of words (id’s) on nodes
• Roots are in 3-dimensional matrix
• Nodes has 2-dimensional matrix of children
Root
• 3 dimensional matrix of root nodes with linked shuffled lists
– alphabet dimension
– word length dimension
– character position dimension
• Example
– We put the word “NAUTICAL” into nodes [N][8][1], [A][8][2], [U][8][3], …,
[L][8][8]
– When we search for pattern “. . U . . . . .”, we are looking into root node [U][8][3]
where we find word “NAUTICAL” in linked list
Root
Child nodes
• 2 dimensional matrix of child nodes with linked shuffled lists
– alphabet dimension
– word length dimension – can be determine from ancestor
– character position dimension
Searching algorithm
• Searching for pattern “. . T . E R . .”
1. Get the first defined character, pattern length and the position of first
defined character (T, 8, 3). Get a node of three-dimensional array data structure
at [character][length][position] ([T][8][3]). Continue to step 2 with this node.
2. If a node is null, string with this pattern does not exists. – END.
If a node is not null and a node has not children (leaf node) or pattern has no
further defined characters, find the first string in a node list which matches the
pattern. Return founded string or null if no string matches the pattern. – END.
If a node is not null and a node has children (not leaf node), take the next
defined character in pattern (E, position 5) and access two-dimensional array of
children nodes of node at element [position][character] ([5][E]), go to step 2
with the given node.
Complexity of algorithm
• We can set MaxListSize on leaf nodes, which determine the
complexity to O(L+MaxListSize), where L is the length of the string
• low MaxListSize = fast searching, high memory consumption,
slow initializing
• High MaxListSize = slow searching, low memory consumption,
fast initializing
• Recommendation
– Set it based on purpose, dictionary size
– Create data structure only once and share it
Other requirements
• Get every word only once
– Creating array map with boolean value “used” and comparing and updating it
– Function reset, which set all values to “not used” - O(N)
• Get randomly chosen words
– All linked list are shuffled after initialization
– After finding the word, we put the word on the end of linked list – O(1)
• Get words with pattern without character e.g. “. . . . . . .”
– Creating special linked lists with all sizes and put the words from dictionary there
Testing Results
• Dictionary with 225 thousands word
• Generating 5 000 word search games of size 25x25
• More than 1300 times faster than naive algorithm
We used for testing HP ProBook 6550b with configuration Win 7 Professional 64bit, Intel® Core ™ i5 CPU M450 2cores 2.40GHz, 4GB RAM, Java 7.
MaxListSize
Initializing
time (s)
Generating
time (s)
Memory
consumption
(MB)
Unlimited
1,508 989,643 86
5000
2,726 839,294 101
1000
4,843 400,539 265
500
7,062 324,728 340
100
16,141 279,410 808
Naive algorithm O(N) 0,095 381 073,600 15
Conclusion
• We design and implement fast in-memory data structure for searching
string patterns with fixed length
• Dynamic structure, up to O(1) complexity
• Randomly chosen words matching the pattern, each founded only
once
• Options to reset data structure, to get all words again without
initializing data structure ( complexity O(N) )
Thank you for your attention!
lubos.takac@gmail.com

More Related Content

What's hot

PROLOG: Introduction To Prolog
PROLOG: Introduction To PrologPROLOG: Introduction To Prolog
PROLOG: Introduction To Prolog
DataminingTools Inc
 
Prolog (present)
Prolog (present) Prolog (present)
Prolog (present) Melody Joey
 
Introduction To Data Structures.
Introduction To Data Structures.Introduction To Data Structures.
Introduction To Data Structures.
Education Front
 
Introduction to Data structure & Algorithms - Sethuonline.com | Sathyabama Un...
Introduction to Data structure & Algorithms - Sethuonline.com | Sathyabama Un...Introduction to Data structure & Algorithms - Sethuonline.com | Sathyabama Un...
Introduction to Data structure & Algorithms - Sethuonline.com | Sathyabama Un...
sethuraman R
 
Prolog Programming : Basics
Prolog Programming : BasicsProlog Programming : Basics
Prolog Programming : Basics
Mitul Desai
 
Introduction To Autumata Theory
 Introduction To Autumata Theory Introduction To Autumata Theory
Introduction To Autumata Theory
Abdul Rehman
 
Toward Description Generation for Tables in Scientific Articles
Toward Description Generation for Tables in Scientific ArticlesToward Description Generation for Tables in Scientific Articles
Toward Description Generation for Tables in Scientific Articles
JUNJIEXu9
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
Rohit Rai
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
Ashim Lamichhane
 
Data structure using c++
Data structure using c++Data structure using c++
Data structure using c++
Prof. Dr. K. Adisesha
 
Data Structure Basics
Data Structure BasicsData Structure Basics
Data Structure Basics
Shakila Mahjabin
 
Introduction to XPath
Introduction to XPathIntroduction to XPath
Introduction to XPath
torp42
 
Mca iii dfs u-4 tree and graph
Mca iii dfs u-4 tree and graphMca iii dfs u-4 tree and graph
Mca iii dfs u-4 tree and graph
Rai University
 
Lecture 8 strings and characters
Lecture 8  strings and charactersLecture 8  strings and characters
Lecture 8 strings and charactersalvin567
 
Ch02
Ch02Ch02
Data Structure # vpmp polytechnic
Data Structure # vpmp polytechnicData Structure # vpmp polytechnic
Data Structure # vpmp polytechnic
lavparmar007
 
Vi INFOTECH php-syllabus
Vi INFOTECH php-syllabusVi INFOTECH php-syllabus
Vi INFOTECH php-syllabus
ViINFOTECH
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
Hanif Durad
 

What's hot (19)

PROLOG: Introduction To Prolog
PROLOG: Introduction To PrologPROLOG: Introduction To Prolog
PROLOG: Introduction To Prolog
 
Prolog (present)
Prolog (present) Prolog (present)
Prolog (present)
 
Introduction To Data Structures.
Introduction To Data Structures.Introduction To Data Structures.
Introduction To Data Structures.
 
Introduction to Data structure & Algorithms - Sethuonline.com | Sathyabama Un...
Introduction to Data structure & Algorithms - Sethuonline.com | Sathyabama Un...Introduction to Data structure & Algorithms - Sethuonline.com | Sathyabama Un...
Introduction to Data structure & Algorithms - Sethuonline.com | Sathyabama Un...
 
Prolog Programming : Basics
Prolog Programming : BasicsProlog Programming : Basics
Prolog Programming : Basics
 
Introduction To Autumata Theory
 Introduction To Autumata Theory Introduction To Autumata Theory
Introduction To Autumata Theory
 
Toward Description Generation for Tables in Scientific Articles
Toward Description Generation for Tables in Scientific ArticlesToward Description Generation for Tables in Scientific Articles
Toward Description Generation for Tables in Scientific Articles
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
Data structure using c++
Data structure using c++Data structure using c++
Data structure using c++
 
Data Structure Basics
Data Structure BasicsData Structure Basics
Data Structure Basics
 
Introduction to XPath
Introduction to XPathIntroduction to XPath
Introduction to XPath
 
Mca iii dfs u-4 tree and graph
Mca iii dfs u-4 tree and graphMca iii dfs u-4 tree and graph
Mca iii dfs u-4 tree and graph
 
Lecture 8 strings and characters
Lecture 8  strings and charactersLecture 8  strings and characters
Lecture 8 strings and characters
 
Ch02
Ch02Ch02
Ch02
 
Data Structure # vpmp polytechnic
Data Structure # vpmp polytechnicData Structure # vpmp polytechnic
Data Structure # vpmp polytechnic
 
Vi INFOTECH php-syllabus
Vi INFOTECH php-syllabusVi INFOTECH php-syllabus
Vi INFOTECH php-syllabus
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
 
Data structures
Data structures Data structures
Data structures
 

Viewers also liked

2014 dti monitoring-solution_for_dangerous_goods_carried_by_intermodal_transport
2014 dti monitoring-solution_for_dangerous_goods_carried_by_intermodal_transport2014 dti monitoring-solution_for_dangerous_goods_carried_by_intermodal_transport
2014 dti monitoring-solution_for_dangerous_goods_carried_by_intermodal_transport
kvaderlipa
 
2014 dt takac-radius-degree_layout-fast_and_easy_graph_visualization_layout
2014 dt takac-radius-degree_layout-fast_and_easy_graph_visualization_layout2014 dt takac-radius-degree_layout-fast_and_easy_graph_visualization_layout
2014 dt takac-radius-degree_layout-fast_and_easy_graph_visualization_layout
kvaderlipa
 
Art & Science Data Visualization
Art & Science Data VisualizationArt & Science Data Visualization
Art & Science Data Visualization
kvaderlipa
 
Visualization of Large Multivariate Data Sets using Parallel Coordinates
Visualization of Large Multivariate Data Sets using Parallel CoordinatesVisualization of Large Multivariate Data Sets using Parallel Coordinates
Visualization of Large Multivariate Data Sets using Parallel Coordinates
kvaderlipa
 
Design and Development of New Automatic on-line Media Monitoring System
Design and Development of New Automatic on-line Media Monitoring SystemDesign and Development of New Automatic on-line Media Monitoring System
Design and Development of New Automatic on-line Media Monitoring System
kvaderlipa
 
Big data, Hadoop, NoSQL DB - introduction
Big data, Hadoop, NoSQL DB - introductionBig data, Hadoop, NoSQL DB - introduction
Big data, Hadoop, NoSQL DB - introduction
kvaderlipa
 
Ebolusyon ng salapi
Ebolusyon ng salapiEbolusyon ng salapi
Ebolusyon ng salapi
Patrick Jordan Paz
 

Viewers also liked (7)

2014 dti monitoring-solution_for_dangerous_goods_carried_by_intermodal_transport
2014 dti monitoring-solution_for_dangerous_goods_carried_by_intermodal_transport2014 dti monitoring-solution_for_dangerous_goods_carried_by_intermodal_transport
2014 dti monitoring-solution_for_dangerous_goods_carried_by_intermodal_transport
 
2014 dt takac-radius-degree_layout-fast_and_easy_graph_visualization_layout
2014 dt takac-radius-degree_layout-fast_and_easy_graph_visualization_layout2014 dt takac-radius-degree_layout-fast_and_easy_graph_visualization_layout
2014 dt takac-radius-degree_layout-fast_and_easy_graph_visualization_layout
 
Art & Science Data Visualization
Art & Science Data VisualizationArt & Science Data Visualization
Art & Science Data Visualization
 
Visualization of Large Multivariate Data Sets using Parallel Coordinates
Visualization of Large Multivariate Data Sets using Parallel CoordinatesVisualization of Large Multivariate Data Sets using Parallel Coordinates
Visualization of Large Multivariate Data Sets using Parallel Coordinates
 
Design and Development of New Automatic on-line Media Monitoring System
Design and Development of New Automatic on-line Media Monitoring SystemDesign and Development of New Automatic on-line Media Monitoring System
Design and Development of New Automatic on-line Media Monitoring System
 
Big data, Hadoop, NoSQL DB - introduction
Big data, Hadoop, NoSQL DB - introductionBig data, Hadoop, NoSQL DB - introduction
Big data, Hadoop, NoSQL DB - introduction
 
Ebolusyon ng salapi
Ebolusyon ng salapiEbolusyon ng salapi
Ebolusyon ng salapi
 

Similar to Fast Exact String Pattern-Matching Algorithm for Fixed Length Patterns

Processing data with Python, using standard library modules you (probably) ne...
Processing data with Python, using standard library modules you (probably) ne...Processing data with Python, using standard library modules you (probably) ne...
Processing data with Python, using standard library modules you (probably) ne...
gjcross
 
Suffix Tree and Suffix Array
Suffix Tree and Suffix ArraySuffix Tree and Suffix Array
Suffix Tree and Suffix Array
Harshit Agarwal
 
Tries .ppt
Tries .pptTries .ppt
Tries .ppt
SumitKumar363528
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
Akhil Kaushik
 
Semi-automated Exploration and Extraction of Data in Scientific Tables
Semi-automated Exploration and Extraction of Data in Scientific TablesSemi-automated Exploration and Extraction of Data in Scientific Tables
Semi-automated Exploration and Extraction of Data in Scientific Tables
Elsevier
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
Julie Iskander
 
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
HendraPurnama31
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Andrew Ferlitsch
 
numpy.pdf
numpy.pdfnumpy.pdf
DSJ_Unit I & II.pdf
DSJ_Unit I & II.pdfDSJ_Unit I & II.pdf
DSJ_Unit I & II.pdf
Arumugam90
 
Data structure and algorithm using java
Data structure and algorithm using javaData structure and algorithm using java
Data structure and algorithm using java
Narayan Sau
 
python-numpyandpandas-170922144956 (1).pptx
python-numpyandpandas-170922144956 (1).pptxpython-numpyandpandas-170922144956 (1).pptx
python-numpyandpandas-170922144956 (1).pptx
Akashgupta517936
 
Towards advanced data retrieval from learning objects repositories
Towards advanced data retrieval from learning objects repositoriesTowards advanced data retrieval from learning objects repositories
Towards advanced data retrieval from learning objects repositoriesValentina Paunovic
 
Unit -I Toc.pptx
Unit -I Toc.pptxUnit -I Toc.pptx
Unit -I Toc.pptx
viswanath kani
 
Numpy.pdf
Numpy.pdfNumpy.pdf
Numpy.pdf
Arvind Pathak
 
Python with data Sciences
Python with data SciencesPython with data Sciences
Python with data Sciences
Krishna Mohan Mishra
 
Numpy
NumpyNumpy
Numpy
ToniyaP1
 
L1 - Recap.pdf
L1 - Recap.pdfL1 - Recap.pdf
L1 - Recap.pdf
Ifat Nix
 
Text classification using Text kernels
Text classification using Text kernelsText classification using Text kernels
Text classification using Text kernels
Dev Nath
 

Similar to Fast Exact String Pattern-Matching Algorithm for Fixed Length Patterns (20)

Processing data with Python, using standard library modules you (probably) ne...
Processing data with Python, using standard library modules you (probably) ne...Processing data with Python, using standard library modules you (probably) ne...
Processing data with Python, using standard library modules you (probably) ne...
 
Suffix Tree and Suffix Array
Suffix Tree and Suffix ArraySuffix Tree and Suffix Array
Suffix Tree and Suffix Array
 
Tries .ppt
Tries .pptTries .ppt
Tries .ppt
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Semi-automated Exploration and Extraction of Data in Scientific Tables
Semi-automated Exploration and Extraction of Data in Scientific TablesSemi-automated Exploration and Extraction of Data in Scientific Tables
Semi-automated Exploration and Extraction of Data in Scientific Tables
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
 
numpy.pdf
numpy.pdfnumpy.pdf
numpy.pdf
 
DSJ_Unit I & II.pdf
DSJ_Unit I & II.pdfDSJ_Unit I & II.pdf
DSJ_Unit I & II.pdf
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
Data structure and algorithm using java
Data structure and algorithm using javaData structure and algorithm using java
Data structure and algorithm using java
 
python-numpyandpandas-170922144956 (1).pptx
python-numpyandpandas-170922144956 (1).pptxpython-numpyandpandas-170922144956 (1).pptx
python-numpyandpandas-170922144956 (1).pptx
 
Towards advanced data retrieval from learning objects repositories
Towards advanced data retrieval from learning objects repositoriesTowards advanced data retrieval from learning objects repositories
Towards advanced data retrieval from learning objects repositories
 
Unit -I Toc.pptx
Unit -I Toc.pptxUnit -I Toc.pptx
Unit -I Toc.pptx
 
Numpy.pdf
Numpy.pdfNumpy.pdf
Numpy.pdf
 
Python with data Sciences
Python with data SciencesPython with data Sciences
Python with data Sciences
 
Numpy
NumpyNumpy
Numpy
 
L1 - Recap.pdf
L1 - Recap.pdfL1 - Recap.pdf
L1 - Recap.pdf
 
Text classification using Text kernels
Text classification using Text kernelsText classification using Text kernels
Text classification using Text kernels
 

Recently uploaded

Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 

Recently uploaded (20)

Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 

Fast Exact String Pattern-Matching Algorithm for Fixed Length Patterns

  • 1. Fast Exact String Pattern-Matching Algorithm for Fixed Length Patterns Ing. Ľuboš Takáč PhD student Faculty of Management Science and Informatics University of Žilina
  • 2. Presentation overview • Motivation • Problem Definition • Existing Solutions • Our Implemented Algorithm • Testing Results • Conclusion
  • 3. Motivation • Word search game generator • Searching string patterns with fixed length – M . . . E R – . . . A H – . . . . .
  • 4. Problem Definition • Design fast in-memory data structure (class) • Requirements – fast searching, if it is possible with O(1) complexity – each founded word get only once – each founded word must be randomly chosen – founded word have to match the pattern class Model FastStringPatternSearch + FastStringPatternSearch(String[], Random) + FastStringPatternSearch(String[]) + reset() : void + searchPattern(String) : String
  • 5. Existing Solutions • Relational DB table with full-text index - access to hard drive • Linked List or array in memory – O(N) complexity • Indexing of array – necessary to index all possible combination of patterns to have O(1) complexity Number of undefined positions 0 1 2 3 4 5 6 7 8 Example of pattern PATTER NS PATT- RNS PA-TE- NS -AT-- RNS P-T-E--S -A--ER-- --TT---- ----E--- -------- All combinations count 1 8 28 56 70 56 28 8 1 Total combinations count 256
  • 6. Our Implemented Algorithm • Dynamic in-memory tree(s) with linked list of words (id’s) on nodes • Roots are in 3-dimensional matrix • Nodes has 2-dimensional matrix of children
  • 7. Root • 3 dimensional matrix of root nodes with linked shuffled lists – alphabet dimension – word length dimension – character position dimension • Example – We put the word “NAUTICAL” into nodes [N][8][1], [A][8][2], [U][8][3], …, [L][8][8] – When we search for pattern “. . U . . . . .”, we are looking into root node [U][8][3] where we find word “NAUTICAL” in linked list
  • 9. Child nodes • 2 dimensional matrix of child nodes with linked shuffled lists – alphabet dimension – word length dimension – can be determine from ancestor – character position dimension
  • 10. Searching algorithm • Searching for pattern “. . T . E R . .” 1. Get the first defined character, pattern length and the position of first defined character (T, 8, 3). Get a node of three-dimensional array data structure at [character][length][position] ([T][8][3]). Continue to step 2 with this node. 2. If a node is null, string with this pattern does not exists. – END. If a node is not null and a node has not children (leaf node) or pattern has no further defined characters, find the first string in a node list which matches the pattern. Return founded string or null if no string matches the pattern. – END. If a node is not null and a node has children (not leaf node), take the next defined character in pattern (E, position 5) and access two-dimensional array of children nodes of node at element [position][character] ([5][E]), go to step 2 with the given node.
  • 11. Complexity of algorithm • We can set MaxListSize on leaf nodes, which determine the complexity to O(L+MaxListSize), where L is the length of the string • low MaxListSize = fast searching, high memory consumption, slow initializing • High MaxListSize = slow searching, low memory consumption, fast initializing • Recommendation – Set it based on purpose, dictionary size – Create data structure only once and share it
  • 12. Other requirements • Get every word only once – Creating array map with boolean value “used” and comparing and updating it – Function reset, which set all values to “not used” - O(N) • Get randomly chosen words – All linked list are shuffled after initialization – After finding the word, we put the word on the end of linked list – O(1) • Get words with pattern without character e.g. “. . . . . . .” – Creating special linked lists with all sizes and put the words from dictionary there
  • 13. Testing Results • Dictionary with 225 thousands word • Generating 5 000 word search games of size 25x25 • More than 1300 times faster than naive algorithm We used for testing HP ProBook 6550b with configuration Win 7 Professional 64bit, Intel® Core ™ i5 CPU M450 2cores 2.40GHz, 4GB RAM, Java 7. MaxListSize Initializing time (s) Generating time (s) Memory consumption (MB) Unlimited 1,508 989,643 86 5000 2,726 839,294 101 1000 4,843 400,539 265 500 7,062 324,728 340 100 16,141 279,410 808 Naive algorithm O(N) 0,095 381 073,600 15
  • 14. Conclusion • We design and implement fast in-memory data structure for searching string patterns with fixed length • Dynamic structure, up to O(1) complexity • Randomly chosen words matching the pattern, each founded only once • Options to reset data structure, to get all words again without initializing data structure ( complexity O(N) )
  • 15. Thank you for your attention! lubos.takac@gmail.com