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
Write a program that will open a file named thisFile.txt and write every other line into the file thatFile.txt. Assume the input
Naily [24]

Answer:

Check the explanation

Explanation:

The programmable code to solve the question above will be written in a python programming language <u><em>(which is a high-level, interpreted, general-purpose programming language.)</em></u>

<u><em /></u>

f = open('thisFile.txt', 'r')

w = open('thatFile.txt', 'w')

count = 0

for line in f:

   if count % 2 == 0:

       w.write(line)

   count += 1

w.close()

f.close()

4 0
3 years ago
When i add someone to canvas course, do they get an invitation?.
stira [4]
<h2>Read</h2>

Explanation:

Canvas generates a course invitation when an enrollment is manually added to the course. (Find that in goggle)

Knew that I'm just bad at explaining lol

5 0
2 years ago
What is a program file​
Fantom [35]

Answer:

Program Files is the directory name of a standard folder in Microsoft Windows operating systems in which applications that are not part of the operating system are conventionally installed.

Explanation:

7 0
3 years ago
You are writing a device driver for an audio device connected to your computer. Your code needs to determine if the device is bu
Zepler [3.9K]

Answer: hello the options related to your question is missing attached below is the complete question and options

answer : Read the status register ( A )

Explanation:

To determine if the device is busy or ready to accept a new command the line of action is to write a code that will Read the status register. A status register   is a hardware register which contains the information about the processor of the device ( i.e. whether the processor is busy or ready )

5 0
3 years ago
Which of the following answers refers to a system containing mappings of domain names to various types of data, such as for exam
Dvinal [7]

Answer:

Option B: DNS

Explanation:

Domain Name Server (DNS) is analogous to a phone book where people can look up a person name through numerical phone number. A DNS server is a database that host a database of public IP addresses (e.g. 64.233.160.0) and their associated hostname (e.g. google.com).

Whenever we type domain name in the address bar of our browser (e.g. google.com), that domain will be delivered to DNS server. Inside DNS server the URL will be mapped with its corresponding IP address making it possible for the web request to reach the the target server.

6 0
3 years ago
Other questions:
  • Your friend is working on fixing their Homework assignment. They need a lot of help. You know all the bugs in the file, but due
    12·1 answer
  • Given a typical magnetic hard drive with five platters, answer the following:
    5·1 answer
  • 1. Describe a linear search (explain how it works).
    13·1 answer
  • Is spread spectrum transmission done for security reasons in commercial WLANs?
    13·1 answer
  • (1 consider the following function definition: int func(int x, double y, char u, string name { //function body } which of the fo
    7·1 answer
  • Which of the following would you not see on a windows 10 start menu?
    6·1 answer
  • Systems Software, Inc., is introducing a new piece of sophisticated graphics software. A recently hired writer has been assigned
    8·1 answer
  • How do computer users benefit from the increased speed?
    9·1 answer
  • How does polymorphism enable you to program "in the general" rather than "in the specific"? Discuss the key advantages of progra
    11·1 answer
  • what are the main technologies that have contributed to be growth and commercialization of the Internet
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!