brute force algorithm

14
BRUTE FORCE ALGORITHM MADE BY: Rakshita tuli 1469it Salika Chaudhary 1477it

Upload: rakshita-tuli

Post on 22-Oct-2014

1.341 views

Category:

Documents


77 download

DESCRIPTION

This is a type of pattern matching algorithm used in information retrieval

TRANSCRIPT

Page 1: Brute Force Algorithm

BRUTE FORCE ALGORITHM

MADE BY:Rakshita tuli 1469it

Salika Chaudhary 1477it

Page 2: Brute Force Algorithm

INDEX Brute Force Brute Force String Matching Algorithm Example Efficiency of Brute force algorithm Strength of Brute force algorithm Weaknesses of Brute force

algorithm

Page 3: Brute Force Algorithm

Exact Pattern Matching String matching algorithms or pattern matching

algorithms try to find a place where one or several strings (also called patterns) are found within a larger string or text.

Various pattern matching algorithms are :• Brute force algorithm• Boyer Moore Algorithm• Aho - Corasik Algorithm etc.

Page 4: Brute Force Algorithm

Brute Force

A straightforward approach, usually based directly on the problem’s statement and definitions of the concepts involved

Examples:1. String and pattern matching

2. Computing n!

3. Multiplying two matrices

4. Searching for a key of a given value in a list

Page 5: Brute Force Algorithm

Brute-Force String Matching pattern: a string of m characters to search for text: a (longer) string of n characters to search in problem: find a substring in the text that matches the

pattern

Brute-force algorithmStep 1 Align pattern at beginning of textStep 2 Moving from left to right, compare each character of

pattern to the corresponding character in text until all characters are found to match (successful search); or a mismatch is detected

Step 3 While pattern is not found and the text is not yet exhausted, realign pattern one position to the right and repeat Step 2

Page 6: Brute Force Algorithm

Algorithm

Page 7: Brute Force Algorithm

Examples of Brute-Force String Matching

Page 8: Brute Force Algorithm

Efficiency The expected number of comparisons when

searching an input text string of n characters for a pattern of m characters is:

Where NC is expected number of comparisons and c is the size of alphabet of the text.

Page 9: Brute Force Algorithm

Efficiency Brute-force pattern matching runs in time O(nm).

Page 10: Brute Force Algorithm

Challenges

Page 11: Brute Force Algorithm

Brute force strengths Strengths:

It is wide applicable.

It is not complex in nature unlike other algorithms.

It yields reasonable algorithms for some important problems

searching; string matching; matrix multiplication

It yields standard algorithms for simple computational tasks

sum/product of n numbers; finding max/min in a list

Page 12: Brute Force Algorithm

Brute force weaknesses Weaknesses:

It rarely yields efficient algorithms

Some brute force algorithms are unacceptably slow

e.g., the recursive algorithm for computing Fibonacci numbers

It is not as constructive/creative as some other design techniques

Page 13: Brute Force Algorithm

Applications parsers.

spam filters.

digital libraries.

screen scrapers.

word processors.

web search engines.

natural language processing.

computational molecular biology.

feature detection in digitized images. . . .

Page 14: Brute Force Algorithm