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]
2 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]2 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
The company generates a lot of revenue and is rapidly growing. They're expecting to hire hundreds of new employees in the next y
uysha [10]

Answer:

The most appropriate way to deal with the situation presented above is to acquire more space at the current office site at additional rent beforehand.

Explanation:

The Scaling of a revenue-generating business is a crucial task in which a lot of pre-planning and thinking is required.

In order to scale the business in the next year, the planning of it is to be carried out at the moment and proper necessary arrangements are ensured. These steps could be one from:

  • Looking for bigger spaces for renting for a full shift of the operations
  • Looking for a site office for an additional office
  • Acquiring more space in the current office site.

This process would result in acquiring a bigger place beforehand but in order to mitigate the risk, try to keep the place in view by providing them a bare minimum advance for the additional units.

8 0
3 years ago
A wet-carpet cleaner that carries it's own water supply has water pressure created by a.
QveST [7]
The correct answer of the given question above would be option D. A wet-carpet cleaner that carries it's own water supply has water pressure created by a MOTOR-DRIVE PUMP. T<span>his product is easy to use, strong, and highly durable. Hope this answers your question. Have a great day!</span>
8 0
3 years ago
Read 2 more answers
Pleaseee need help ASAP!!<br><br> Will mark BRAINLIEST!! :)
torisob [31]

Answer:

The correct option is Option B

Explanation:

We need to find examples of client-side code.

Client Side code: The part of code, that doesn't require server for performing specific task

SO, The correct option is Option B

Prompt for special characters in user name

Reason: We can use alert to generate prompt using JavaScript or through validation and it can be done on client side.

All other options, we need to hit the server to perform the task, So they are not client-side code.

6 0
2 years ago
Assume you are part of the systems development team at a medium-sized organization. You have just completed the database design
nexus9112 [7]

Answer:

Please see the attached file for the complete answer.

Explanation:

Download pdf
5 0
3 years ago
What is an unintended consequence of pesticides used on crops
RUDIKE [14]
<span>They leave a residue on the surface or inside the crop treated. </span>
3 0
3 years ago
Read 2 more answers
Other questions:
  • Barr the Bear has started a business to sell fish to Poe and his fellow penguins. The penguin customers submit many fish orders,
    12·1 answer
  • Assume you have just started a new job, have a car loan, and have a student loan. You have just received a cash gift of $1,000 f
    14·1 answer
  • .When an argument is passed ______________, the called method can access and modify the caller’s original data directly.
    8·1 answer
  • What is the purpose of a scatter plot introduction to computer applications
    6·2 answers
  • Prompt the user to input an integer, a double, a character, and a string, storing each into separate variables. Then, output tho
    9·1 answer
  • Could someone please explain to me the an electrical circuit.
    13·2 answers
  • What games do you play?<br><br><br> Be sure not to report any answers!
    5·1 answer
  • What is a field on a table
    13·1 answer
  • Write the two features of a mouse.​
    9·1 answer
  • What types of company functions are aided by ERP?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!