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
Can a computer evaluate an expression to something between true and false? Can you write an expression to deal with a "maybe" an
Maurinko [17]

Answer:

yes a computer can evaluate expressions depends on the computer for the maybe expression

Explanation:

4 0
3 years ago
Read 2 more answers
What is NOT an issue associated with tag management systems? There is no automation available for tag management systems. Managi
SSSSS [86.1K]

Answer:

Managing tags means experience with the programming language to utilize them.

Explanation:

In different markets, tags are used to assigned prices and values to different products. To make these tags "tag management systems" are deployed to manage and create these tags.

Tag management system is software, that is used to create the tags with ease. There is no need of coding or programming while creating tags.

<em>So we can say that, There is no issue of Managing tags means experience with the programming language to utilize them.</em>

5 0
3 years ago
You are given a graph G = (V, E) with positive edge weights, and a minimum spanning tree T = (V, E’) with respect to these weigh
matrenka [14]
C vraiment très facile
Si tu a besoin d’aide recontacter moi
7 0
2 years ago
what new technology led to the chaos that spurred the establishment of the federal communications commission?
adelina 88 [10]

Answer:

The digital read Harry quaant

3 0
1 year ago
An _____provider is a business that provides individuals and companies access to the internet for free
boyakko [2]

Answer:A B

access provider Business that provides individuals and companies access to the Internet free or for a fee.

Explanation:

6 0
2 years ago
Read 2 more answers
Other questions:
  • Write a program with a function that accepts a string as an argument and returns a copy of the string with the first character o
    11·1 answer
  • What type of network is capable of delivering voice, video streams, text, and graphics between many different types of devices o
    15·1 answer
  • All of the following are current key technology trends raising ethical issues except:_________
    13·1 answer
  • Given a Fahrenheit value temperatureFahrenheit, write a statement that assigns temperatureCelsius with the equivalent Celsius va
    9·1 answer
  • You recently started working part-time in a retail store, and are learning about the reading devices your store uses. Your store
    6·1 answer
  • Consider the following program segment: //include statement(s) //using namespace statement int main() { //variable declaration /
    9·1 answer
  • Write a python program that requests a positive integer from the user, determines if it is a composite, a prime or neither prime
    8·1 answer
  • . Define the process of Technological relationship
    12·1 answer
  • Select the statement which most accurately describes the benefits and drawbacks of working from home and telecommuting.
    13·2 answers
  • A large organization is struggling to close the gaps in skill levels that exist between its employees and those from competing c
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!