Data Structures Lerax  v3.0-102-gaf18
Opinionated Data Structures & Algorithms
Loading...
Searching...
No Matches
Search Algorithms

Functions implementing various search algorithms. More...

Functions

int search_naive (char *text, const char *pattern)
 Finds the first occurrence of a pattern in a text using the naive string searching algorithm.
int search_kmp (char *text, const char *pattern)
 Finds the first occurrence of a pattern in a text using the Knuth-Morris-Pratt (KMP) algorithm.
int search_bm (char *text, const char *pattern)
 Finds the first occurrence of a pattern in a text using the Boyer-Moore string searching algorithm.
int search_kr (char *text, const char *pattern)
 Finds the first occurrence of a pattern in a text using the Karp-Rabin algorithm.

Detailed Description

Functions implementing various search algorithms.

Function Documentation

◆ search_bm()

int search_bm ( char * text,
const char * pattern )

Finds the first occurrence of a pattern in a text using the Boyer-Moore string searching algorithm.

Parameters
textThe text to search in.
patternThe pattern to search for.
Returns
The index of the first occurrence of the pattern in the text, or -1 if the pattern is not found.

◆ search_kmp()

int search_kmp ( char * text,
const char * pattern )

Finds the first occurrence of a pattern in a text using the Knuth-Morris-Pratt (KMP) algorithm.

Parameters
textThe text to search in.
patternThe pattern to search for.
Returns
The index of the first occurrence of the pattern in the text, or -1 if the pattern is not found.

◆ search_kr()

int search_kr ( char * text,
const char * pattern )

Finds the first occurrence of a pattern in a text using the Karp-Rabin algorithm.

Parameters
textThe text to search in.
patternThe pattern to search for.
Returns
The index of the first occurrence of the pattern in the text, or -1 if the pattern is not found.

◆ search_naive()

int search_naive ( char * text,
const char * pattern )

Finds the first occurrence of a pattern in a text using the naive string searching algorithm.


    Copyright 2025 Manoel Vilela

    Author: Manoel Vilela
   Contact: manoel_vilela@engineer.com

Organization: ITA


Parameters
textThe text to search in.
patternThe pattern to search for.
Returns
The index of the first occurrence of the pattern in the text, or -1 if the pattern is not found.