ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
Nondeterminism.h File Reference

The nondeterministic algorithms of section 18.2 simulated by enumeration (section 18.3). More...

#include "ADS/Contract.h"
#include <cstddef>
#include <vector>
#include "ADS/complexity/impl/Nondeterminism.tpp"

Go to the source code of this file.

Classes

class  ADS::Chooser
 the simulation of choice(), success and failure More...

Namespaces

namespace  ADS

Detailed description

The nondeterministic algorithms of section 18.2 simulated by enumeration (section 18.3).

A nondeterministic algorithm is a function that receives a Chooser and calls choice( k ) to pick one of \( k \) alternatives, returning true for success and false for failure; it answers YES if some sequence of choices leads to success. run() replays the algorithm on every sequence of choices, in increasing order, a visit in depth of the tree of the choices that backtracks on the last choice that still has an untried alternative, and stops at the first success; its time is the number of leaves of the tree times the time of a run, exponential in the height of the tree, while the nondeterministic algorithm takes as much as one path.

The contracts [see Contract.h]: choice() needs \( k \ge 1 \) and returns a choice of \( [ 0 , k ) \). The operations are defined in Nondeterminism.tpp.

See also
A. Montresor, Algoritmi e Strutture Dati, 2025, sections 18.2 and 18.3, https://algoritmicamente.it/materiali/libro/capitoli/cap18.pdf
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa