1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Katen [24]
3 years ago
8

Write an algorithm that prints out all the subsets of 3 elements of a set of n elements. The elements of the set are stored in a

list that is the input to the algorithm, (you may assume all elements in the list are distinct. The list can be an array). Algorithm: Print_3_Element_Subsets Input: List S of n distinct elements. Output: Print out all 3-element subsets of S. void Print_3_Element_Subsets (int n, const element_type S[])
Computers and Technology
1 answer:
Ksenya-84 [330]3 years ago
7 0

void Print_3_Element_Subsets(int n,const element_type S[])

{

if(n<3) // condition to check if list have less than 3 elements

{

print("No subset found");

}

for(int i =0; i < n ; i++)

{

for(int j =i+1; j < n ; j++)

{

for(int k =j+1; k < n ; k++)

{

print(S[i],S[j],S[k]);

}

}

}

}

C++ Implementation;

#include<cstdlib>

#include<time.h>

using namespace std;

int S1[5]= {1,2,3,4,5};

int n1 = 5;

int S2[2]={1,2};

int n2 = 2;

void Print_3_Element_Subsets(int n,const int S[])

{

if(n<3) // condition to check if list have less than 3 elements

{

printf("No subset found\n");

}

printf("3 Subsets are\n");

for(int i =0; i < n ; i++)

{

for(int j =i+1; j < n ; j++)

{

for(int k =j+1; k < n ; k++)

{

cout<<S[i]<<" "<<S[j]<<" "<<S[k]<<endl;

}

}

}

}

int main()

{

cout<<"Case 1"<<endl;

Print_3_Element_Subsets(n1,S1);

cout<<endl<<"Case 2"<<endl;

Print_3_Element_Subsets(n2,S2);

}

OUTPUT

Case 1

3 Subsets are

1 2 3

1 2 4

1 2 5

1 3 4

1 3 5

1 4 5

2 3 4

2 3 5

2 4 5

3 4 5

Case 2

No subset found

3 Subsets are

--------------------------------

Process exited after 0.0137 seconds with return value 0

Press any key to continue . . .

You might be interested in
High level language is___________
lara31 [8.8K]

Answer:

B. Machine dependent and machine oriented pls mark me branilest

8 0
3 years ago
Blending two or more colours is called​
krek1111 [17]

Answer:

shading?

Explanation:

Ombré /ˈɒmbreɪ/ (literally "shaded" in French) is the blending of one color hue to another, usually moving tints and shades from light to dark. It has become a popular feature for hair coloring, nail art, and even baking, in addition to its uses in home decorating and graphic design.

3 0
3 years ago
Belvedere Street is parallel to St. Anthony Street. Davidson Street is perpendicular to River Street. River Street is parallel t
Sergio039 [100]

Answer:

Davidson street is perpendicular to Belvedere street

Explanation:

Belevedere is street is parallel to Anthony street which is parallel to Rivers street. Also Davidson street is perpendicular to River street which we already know is parallel to Belvedere street since it is parallel to St Anthony street therefore Davidson street is perpendicular to belverdere street as it is perpendicular to all other street listed:Rivers street and St Anthony street

6 0
3 years ago
In addition to format commands that are found in the ribbon, which option is available for more extensive formatting?
eimsori [14]

Answer:

A

Explanation:

5 0
3 years ago
What shortcut bring up the print page
Kobotan [32]
The keyboard shortcut to bring up print on windows is ctrl+P, for Mac it's cmd+P.

Unless, you mean print screen - for that, there is a button that should say prt sc on your keyboard for windows, and for Mac, it's cmd <span>+ ctrl + shift + 3 to save to clipboard (or don't hold down the ctrl to save to your desktop).</span>
7 0
3 years ago
Read 2 more answers
Other questions:
  • is this website just for a bunch of lazy kids bumming off answers? Because if that were the case I'd be one of them.
    9·1 answer
  • Hot five was the famous band of which musician?
    14·1 answer
  • Jessica finds out that the government introduced a new trade policy that will increase import tariffs. She calls for a meeting o
    15·1 answer
  • _____ are special combinations of keys that tell a computer to perform a command.
    9·2 answers
  • Violations of security policies are considered to be a(n) __________ issue upon which proper disciplinary actions must be taken.
    7·1 answer
  • Can I change my username?
    6·1 answer
  • Excel spread sheets are primarily used to
    13·2 answers
  • What error occurs in the following program? #include using namespace std; int main() { int number1, number2, sum; cout &lt;&lt;
    13·1 answer
  • Is it good to work out at the gym one day with hands then the next with feet, then a pattern?
    11·2 answers
  • What is file management?can please help me​
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!