Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that will do the cartesian product of two sets. I have a program but that doesn't do the job properly. #include #include

Write a program that will do the cartesian product of two sets. I have a program but that doesn't do the job properly.

#include #include using namespace std;

void cartesianProduct( string ArraySet1[], string Arrayset2 ) { if ( setA[] || setB[] == '\0') { cout

else { cout

cout

cout

cout

for (int k = 0; k

}

int main() {

const int SIZE1 = 13; const int SIZE2 = 4;

string setA[SIZE1] = {"A","K","Q","J","10","9","8","7","6","5","4","3","2"}; string setB[SIZE2 ] = {"H","C","S","D"}

cartesianProduct (setA, setB);

cartesianProduct (setB, setA);

system("pause"); return 0; }

image text in transcribed

Cartesian Product From Wikipedia In set theory (and, usually, in other parts of mathematics), a Cartesian product is a mathematical operation that returns a set (or product set or simply product) from multiple sets. That is, for sets A and B, the Cartesian product A x Bis the set of all ordered pairs (a, b) where a E A and be B Products can be specified using set-builder notation, e.g AxB La, b)laCA and beB) A table can be created by taking the Cartesian product of a set of rows and a set of columns. If the Cartesian product rows x columns is taken, the cells of the table contain ordered pairs of the form (row value, column value) More generally, a Cartesian product of n sets, also known as an n-fold Cartesian product, can be represented by an array of n dimensions, where each element is an n tuple An ordered pair is a 2-tuple or couple In this assignment write the program represented by (A B-, VAVB P(A B) where PO is a function that displays the cartesian product of A and B if boiO and B are not empty. O Consider a desk of cards where the ranks are the set (A, K, Q,J, 10,9,8,7,6, 5, 4, 3, 2) and the suits are the set jD, H, S, C) Case 1 Let A set of ranks Let B set of suits Case 2 Let A-set of suits Let B - set of ranks Display the results in a manner like 1 2 3 Cartesian Product From Wikipedia In set theory (and, usually, in other parts of mathematics), a Cartesian product is a mathematical operation that returns a set (or product set or simply product) from multiple sets. That is, for sets A and B, the Cartesian product A x Bis the set of all ordered pairs (a, b) where a E A and be B Products can be specified using set-builder notation, e.g AxB La, b)laCA and beB) A table can be created by taking the Cartesian product of a set of rows and a set of columns. If the Cartesian product rows x columns is taken, the cells of the table contain ordered pairs of the form (row value, column value) More generally, a Cartesian product of n sets, also known as an n-fold Cartesian product, can be represented by an array of n dimensions, where each element is an n tuple An ordered pair is a 2-tuple or couple In this assignment write the program represented by (A B-, VAVB P(A B) where PO is a function that displays the cartesian product of A and B if boiO and B are not empty. O Consider a desk of cards where the ranks are the set (A, K, Q,J, 10,9,8,7,6, 5, 4, 3, 2) and the suits are the set jD, H, S, C) Case 1 Let A set of ranks Let B set of suits Case 2 Let A-set of suits Let B - set of ranks Display the results in a manner like 1 2 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions