Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need a program help in either C++ or Java, thanks in advance. The Catalan number

ID: 3716564 • Letter: N

Question

Need a program help in either C++ or Java,

thanks in advance.

The Catalan numbers are an integer sequence Cn that appears in tree-enumeration problems. The first Catalan numbers for n 1, 2, 3,... are 1, 2, 5, 14, 42, 132, A formula generating Cn is: Design two programs that communicate with shared memory using the Win32 API as outlined in Section 8.7.2 The producer process will generate the Catalan sequence and write it to a shared memory object. The consumer process will then read and output the sequence from shared memory. In this instance, the producer process will be passed an integer parameter on the command line specifying how many Catalan numbers to produce (for example, providing 5 on the command line means the producer process will generate the first five Catalan numbers)

Explanation / Answer

using mapping files or java sockets we can share the memory of two programs

program:

import java.*;
import java.util.*;
class fact1
{
int fact2(int a)
{
int b=1,i;
for(i=1;i<=a;i++)
{
b=b*i;
}
return b;
}
}
class a
{
public static void main(String args[])
{
Scanner ss=new Scanner(System.in);
int n,y,x,x1,x2,x3,z;
System.out.println("enter the number");
n=ss.nextInt();
fact1 obj=new fact1();
for(y=0;y<=n;y++)
{
x1=obj.fact2(y+1);
x2=obj.fact2(y);
x3=obj.fact2(2*y);
z=x1*x2;
x=x3/z;
System.out.println(x);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote