+ All Categories
Home > Documents > Searching Algo

Searching Algo

Date post: 07-Apr-2018
Category:
Upload: himanshu-patidar
View: 226 times
Download: 0 times
Share this document with a friend

of 20

Transcript
  • 8/6/2019 Searching Algo

    1/20

    SEARCHING ALGORITHMS:

    The Broad Picture

  • 8/6/2019 Searching Algo

    2/20

    Introduction

    Classes

    Some important algos explained

    Bibliogaphy

  • 8/6/2019 Searching Algo

    3/20

    Searching Algorithm procedure written

    for finding an item with specified

    properties among a collection of items.

    Items maybe stored in database as

    records or as math formulae orprocedures or graphical entities.

  • 8/6/2019 Searching Algo

    4/20

    For virtual search spaces :

    Used in constraint satisfaction problem

    andMax-Min problem Linear Search,Brute Force Search, Binary Search, etc.

    Used in local search methods whereelements of a graph include search space

    Simulated Annealing, Tabu Search,

    Genetic Programming, etc.

  • 8/6/2019 Searching Algo

    5/20

    Used in Tree Search algorithmswhere

    vertices of tree are elements of searchspace and traversing is done in some

    special order (breadth-first ,depth-first)

    BacktrackingandBranch and Bound algo.

  • 8/6/2019 Searching Algo

    6/20

    For sub-structures of a given structure:

    Used in Combinatorial Search algos that look

    for specific sub-structure of a given discretestructure such as a graph, a string or finite

    group Brents algo , Gale Shapley algo , etc.

  • 8/6/2019 Searching Algo

    7/20

    Used in Graph algorithms for finding specificsub-structure in a given graph- sub graphs,circuits, paths, etc. Djikshtras algo, Kruskalsalgo, Prims algo, etc.

    Used in String Searchingalgorithms that searchfor patterns within strings

    Boyer-Moore algo, Knuth-Morris-Pratt algo, BruteForce algo, Karp-Rabin algo, Deterministic FiniteAutomaton algo, etc.

  • 8/6/2019 Searching Algo

    8/20

    For quantum computers :

    Used for designing quantum computers theoretically faster than linear or brute-force search Grovers algorithm.

  • 8/6/2019 Searching Algo

    9/20

    Simulated Annealing: It has analogy with

    annealing in metallurgy, where materials are

    heated and cooled to increase size of its crystals

    and reduce its effects.

    Following analogy, each step of SA algo

    replaces current solution by a random nearby

    solution.

  • 8/6/2019 Searching Algo

    10/20

    Nearby solution is chosen according to diff.

    b/w corresponding function values and global

    parameter T.

    Dependency is such that current solution

    changes almost randomly when T is large, but

    goes downhillas T goes to zero.

  • 8/6/2019 Searching Algo

    11/20

    s s0; e E(s)

    sbest s; ebest e

    k 0

    while k < kmax and e < emaxsnew neighbour(s)

    enew E(snew)

    ifP(e, enew, temp(k/kmax)) > random() then

    s snew; e enewifenew > ebest then

    sbest snew; ebest enew

    k k + 1

    return sbest

    Pseudocode

  • 8/6/2019 Searching Algo

    12/20

    Branch and Bound :B&B is a

    general algorithm for finding optimal solutions of

    various optimization problems.

    Goal is to find theminimumvalue of a

    functionf(x), wherexranges over some

    set Sofadmissible or candidate solutionsor

    search space.

  • 8/6/2019 Searching Algo

    13/20

    It includes two steps:Firstly a splitting

    procedure that in a given set Sreturns two or

    more smaller sets. Its called branching.

    Secondly, it computes upper and lower bounds

    for theminimumvalue off(x)within a given

    subset S. Its called bounding.

  • 8/6/2019 Searching Algo

    14/20

    Three main components of B&B algo:

    1. Bounding function : provides lower bound for thebest solution value obtainable in the subspace,

    2. Strategy: for selecting the live solution subspaceto be investigated in the current iteration, and

    3. Branching rule : to be applied for subdividing

    the subspace considered into two or moresubspaces to be investigated in subsequentiterations.

  • 8/6/2019 Searching Algo

    15/20

    Knuth-Morris-Pratt Algo :

    searches for occurrences of a "word" W within a

    main "text string" S by employing theobservation that when a mismatch occurs, the

    word itself embodies sufficient information to

    determine where the next match could begin,

    thus bypassing re-examination of previouslymatched characters.

  • 8/6/2019 Searching Algo

    16/20

    Consider an attempt at a left position j, that is

    when the window is positioned on the textfactory[j..j+m-1]. Assume that the first

    mismatch occurs betweenx[i] andy[i+j] with 0

    < i

  • 8/6/2019 Searching Algo

    17/20

    When shifting, it is reasonable to expect that a

    prefix vof the pattern matches some suffix of the

    portion u of the text.

    If we want to avoid another immediate

    mismatch, the character following the prefix v in

    the pattern must be different from a. The longest

    such prefix vis called the tagged borderofu.

  • 8/6/2019 Searching Algo

    18/20

    Now letkmpNext[i] be the length of the longestborder ofx[0 ..i-1] followed by a

    character cdifferent fromx[i] and -1 if no such

    tagged border exits, for 0

  • 8/6/2019 Searching Algo

    19/20

    The tablekmpNextcan be computed in O(m)

    The searching phase can be performed

    inO(m+n) time.

    Algo performs at most 2n-1 text character

    comparisons during the searching phase.

  • 8/6/2019 Searching Algo

    20/20

    BIBLIOGRAPHY:

    KNUTHD.E.,MORRIS (Jr) J.H.,PRATTV.R.,

    1977,Fast pattern matching in strings, SIAM

    Journal on Computing

    CORMEN, T.H., LEISERSON, C.E., RIVEST, R.L.,

    1990.Introduction to Algorithms

    http://www-igm.univ-mlv.fr/~lecroq/string/

    www.wikipedia.org


Recommended