Display all subsets of the characters

Assignment Help Computer Engineering
Reference no: EM132194681

Write a C++ program called all_subsets.cpp which displays all subsets of a set. In the problem, your program should read n characters from a user and display all subsets of the characters.

In the program, you can assume that the number of input characters is less than or equal to 15.

Your program should ask a user to enter the number of input characters.

After that, it should read the characters.

For the problem, you can assume that the input characters are always distinct.

The following presents a sample run of the program:

Number of input characters: 2

Enter 2 characters: a c

===== All Subsets =====

empty

{c}

{a}

{a,c}

At the above sample run, the sequence of subsets is not important. Therefore, this result is also fine.

Number of input characters: 2

Enter 2 characters: a c

===== All Subsets =====

{a,c}

empty

{c} {a}

[Hint]: You can use the binary representation of the numbers from 0 to 2n - 1 for the input n. For example, if the number of input characters is 2, all binary numbers from 0 to 22 - 1 (= 3) will be 00, 01, 10, and 11. Try to find a correspondence between a subset and its binary representation.

This is another sample run:

Number of input characters: 3

Enter 2 characters: c d f

===== All Subsets =====

empty {f}

{d}

{d,f}

{c}

{c,f}

{c,d}

{c,d,f}

Reference no: EM132194681

Questions Cloud

Supporters of a higher minimum wage : Why do you think organized labor groups, such as unions, are supporters of a higher minimum wage, even though all of their members earn much more
Ask the user to input the number of rows and columns : The program will fill the arry starting at location [0][0] with the user selected starting number and each element after will be incremented by the user direct.
How a change in the exchange rate affected firm : Describe how a change in the exchange rate affected your firm. Explain what happened to your price and quantity.
Elasticity of demand for a given product or services : What are the two primary factors that determine the elasticity of demand for a given product or services?
Display all subsets of the characters : n the problem, your program should read n characters from a user and display all subsets of the characters.
Explain consistent patterns in feelings and behaviour : HPS307/791 PERSONALITY ASSESSMENT, DEAKIN UNIVERSITY, AUSTRALIA. Explain consistent patterns in thoughts, feelings and behaviour
How it distinguishes normal and inferior goods : Define income elasticity and how it distinguishes normal and inferior goods.
A program to count words and numbers in a plain text file : Words and numbers can be repeated. You can use any algorithm and data structures that you prefer, as long as the results are correct.
A program to calculates a vehicles gas mileage : The program should ask the user to enter the number of gallons of gas the vehicle can hold and the number of miles it can be driven on a full tank.

Reviews

Write a Review

Computer Engineering Questions & Answers

  List and describe the methods for installing software

List and explain the methods for installing software. Conclude with a recommendation for your preferred software installation approach; explain why you believe this is the best approach to install software.

  Write algorithm pseudocode to solve second birthday problem

Write an algorithm in pseudocode to solve the first birthday problem. Write an algorithm in pseudocode to solve the second birthday problem (in general form).

  Prove the logical equivalence of conditional statement

Prove the logical equivalence of conditional statement and contrapositive of two propositional variables using truth table.

  A new column would be added to the table

A table was created, Whse.IStock. This table contains a column, SKU that holds stock numbers. The SKU column was created as a data type char(20) and right-justified the stock numbers with leading blanks.

  Provide discussion of the relative effectiveness of research

Provide a discussion of the relative effectiveness of the research and how it might be improved to gain better results. MAKE SURE INCLUSION OF THE FOLLOWING...... Was there further information that would be helpful that was not found?

  Write an algorithm to delete the node with largest integer

An unique integer is stored in each node of a doubly-linked list which has a reference, start, that points to the first node of the list.

  Write a recursive function to traverse a binary tree

Write a method and the corresponding recursive function to traverse a binary tree (in whatever order you find convenient) and dispose of all its nodes.

  Creating a program that creates a single tips object

Creating a program that creates a single Tips object

  Explain the potential outcomes of not using consistency in

as a software engineer you have been asked to write a paper that describes the use of current technologies with regard

  Describe the six different types of expert review methods

What is expert review? Describe the benefits and limitations of expert review. Describe the six different types of expert review methods.

  What sort of code would you put into a function

What sort of code would you put into a function

  What is the probability it came from box 3

What is the probability of selecting a 0.01 -mu F capacitor, given that box 2 is selected?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd