I have forgotten

COST (GBP)
1.39
0.00
0

# Catalan Triangle Row

Computes the row of the given order in Catalan's triangle.
Controller: CodeCogs

C++

## Catalan Triangle Row

 std::vectorcatalan_triangle_row( int n bool first = true )
The recurrent formula used to generate Catalan's triangle is

$C(0,&space;0)&space;=&space;1&space;\qquad&space;C(i,&space;0)&space;=&space;1&space;\qquad&space;C(i,&space;j)&space;=&space;0,&space;\quad&space;\forall&space;i&space;<&space;j$
$C(i,&space;j)&space;=&space;C(i,&space;j&space;-&space;1)&space;+&space;C(i&space;-&space;1,&space;j)$

The number found at $\inline&space;&space;C(i,&space;i)$ represents the Catalan number of order $\inline&space;&space;i$.

## Example:

#include <codecogs/maths/combinatorics/sequences/catalan_triangle_row.h>
#include <iostream>
int main() {
std::vector<int> row = Maths::Combinatorics::Sequences::catalan_triangle_row(6);
std::cout << "Length of row: " << row.size() << std::endl;
for (int i = 0; i < row.size(); i++)
std::cout << row[i] << "  ";
std::cout << std::endl;
return 0;
}

## Output:

Length of row: 7
1  6  20  48  90  132  132

## References:

SUBSET, a combinatorial functions library created in C++, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.html

### Parameters

 first Default value = true

### Returns

the row of order n in Catalan's triangle, as a standard C++ vector

### Authors

Lucian Bentea (August 2005)
##### Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.