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
As you are working on the Datacenter Edition server, you install a card to connect a set of RAID drives. After the card and driv
sweet [91]

Answer:

by fixing it with card

Explanation:

you have taken out the card I thing

4 0
3 years ago
A detective agency is looking to bust an arms sale. According to available intelligence, the sale is likely to happen in one of
Paha777 [63]

Answer:

Probability Distribution={(A, 4/7), (B, 2/7), (C, 1/7)}

H(X)=5.4224 bits per symb

H(X|Y="not C")=0.54902 bits per symb

Explanation:

P(B)=2P(C)

P(A)=2P(B)

But

P(A)+P(B)+P(C)=1

4P(C)+2P(C)+P(C)=1

P(C)=1/7

Then

P(A)=4/7

P(B)=2/7

Probability Distribution={(A, 4/7), (B, 2/7), (C, 1/7)}

iii

If X={A,B,C}

and P(Xi)={4/7,2/7,1/7}

where  Id =logarithm to base  2

Entropy, H(X)=-{P(A) Id P(A) +P(B) Id P(B) + P(C) Id P(C)}

=-{(1/7)Id1/7 +(2/7)Id(2/7) +(4/7)Id(4/7)}

=5.4224 bits  per symb

if P(C)  =0

P(A)=2P(B)

P(B)=1/3

P(A)=2/3

H(X|Y="not C")= -(1/3)Id(I/3) -(2/3)Id(2/3)

=0.54902 bits per symb

4 0
3 years ago
Do you have to include anything in a body of an email in order for it to send
MArishka [77]

Answer:

You dont have to but if you can its optional

Explanation:

6 0
3 years ago
What are the different ways to represent compounds? Check all that apply. a structural formula a ball model a space-filling mode
bagirrra123 [75]

Answer:

Compound can be represented as a molecular formula,empirical formula, structural formula,ball and stick model, space filling model.

Explanation:

Compounds can be represented as a chemical formula and a molecular model.

A chemical formula shows the number of atoms present in a compound. Whereas, the molecular model shows the geometry of a compound.

The chemical formula can be further divided into 3 types:

1)molecular formula: indicates the actual number of atoms in a compound.

2)empirical formula: indicates the relative number of atoms present in a compound.

3)structural formula: is illustrated in the forms of lines which actually shows the bond(such as covalent bond) and also shows how atoms are connected to each other in a molecule.

Molecular model is preferably a better way to represent a molecule. It is categorised into the following:

1)a ball and stick model: its a three dimensional representation of a compound. The atom(s) in a compound is represented by ball while, their chemical bonds are shown by sticks.

2)A space filling model: its a three dimensional structure,it represents the size and shape of the whole molecule,showing relatively how much space each atom in a molecule occupies.

7 0
3 years ago
Read 2 more answers
A variable of type unsigned short stores a value of 0. If the variable value is incremented, what exception will occur?A. No exc
yulyashka [42]

There are different kinds of variable. The answers are below;

  • If the variable value is incremented, therefore, No <u>exception </u>will occur.
  •  If the variable value is incremented, An <u>Overflow </u>will occur
  • If the variable value is decremented no exception will occur.

<h3>What is Underflow?</h3>

Underflow is a known to be a process or exception that happens if a number calculation is too small to be shown by the CPU or memory.

what causes a overflow is the Adding to a variable when its value is at the upper end of the datatype range.

Learn more about variables from

brainly.com/question/24751617

3 0
3 years ago
Other questions:
  • If you turn your volume to loud on u'r headphones can it break the sound quality of the speaker?
    9·2 answers
  • Obtain a file name from the user, which will contain data pertaining to a 2D array Create a file for each of the following: aver
    5·1 answer
  • Give a logical expression with variables p,q, and r that is true if p and q are false and r is true and is otherwise false.
    5·1 answer
  • In fixed-width files, each record is on a separate line and the fields are separated by a special character.
    7·1 answer
  • List the applications in the CyberOps menu.
    15·1 answer
  • When the atmosphere has too much carbon dioxide in it, the oceans absorb some of it to achieve a new balance. This is an example
    9·2 answers
  • When you use information hiding by selecting which properties and methods of a class to make public, you are assured that your d
    14·1 answer
  • For the purposes of laying out content, the total height of a box is calculated by adding which of the following?
    5·1 answer
  • _________________ is the logical operator if either conditions is True, then the whole statement is TRUE.
    7·1 answer
  • Adding a border to an image is one way to manipulate media to spice up a project. Where do you find the Picture Styles command t
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!