File Anagrams.h

↰ Parent directory (ADS/backtrack)

The anagrams (exercise 16.8): the strings made of all the characters of a given one, in any order, that split into words of a dictionary, written with spaces between the words.

Definition (ADS/backtrack/Anagrams.h)

Detailed Description

The backtrack chooses the characters one at a time, as the permutations do, each distinct character once at a level so that no anagram comes twice, and closes a word whenever the characters since the last space make one: a permutation is pruned as soon as its last part cannot be completed into a word, if the dictionary also tells the prefixes of its words.

The contracts [see File Contract.h]: each sentence found has the letters of the string (checked at level 3). The operations are defined in Anagrams.tpp.

  1. Montresor, Algoritmi e Strutture Dati, 2025, exercise 16.8, https://algoritmicamente.it/materiali/libro/capitoli/cap16.pdf

Donato Meoli

Dipartimento di Informatica Universita’ di Pisa

by Donato Meoli

Includes

Namespaces

Functions