45template <
typename Range>
58 std::cout << label <<
": ";
59 for (
const auto & item :
r)
60 std::cout << std::format(
"{} ", item);
74 const std::string
text =
"aabcaabxaaaz";
75 const std::string pattern =
"aab";
80 std::cout << std::format(
"Z-Algorithm Example\nText : {}\nPattern: {}\n\n",
Classical pattern searching algorithms over strings.
Main namespace for Aleph-w library functions.
Array< size_t > z_search(const std::string_view text, const std::string_view pattern)
Find all occurrences of a pattern using the Z-algorithm.
Array< size_t > z_algorithm(const std::string_view s)
Compute Z-array for a string.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
void print_range(std::string_view label, const Range &r)
Print a label followed by the elements of a range to standard output.
int main()
Example program demonstrating computation of the Z-array and pattern matches using the Z-algorithm.