473,327 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

help to solve this question

1
a set of n people(say a,b,c,d) need to assemble as two different teams in
two different rooms (say r1 and r2) to attend discuss two different
topics. participants are given options to pick the room of their interest,
print all the possible ways in which they can conduct the meetings.(while
printing the output, arrange the possiblities in such a way that no. of
people in r1 is in ascending order, and when the no. of people in r1 are
same, the groups are sorted based on their alphabetical order. note that a
set itself is printed as sorted character list. also assume 2<=n<=26)

sample input:
2

output:
- ab
a b
b a
ab -
Sep 15 '06 #1
3 1476
risby
30
a set of n people(say a,b,c,d) need to assemble as two different teams in
two different rooms (say r1 and r2) to attend discuss two different
topics. participants are given options to pick the room of their interest,
print all the possible ways in which they can conduct the meetings.(while
printing the output, arrange the possiblities in such a way that no. of
people in r1 is in ascending order, and when the no. of people in r1 are
same, the groups are sorted based on their alphabetical order. note that a
set itself is printed as sorted character list. also assume 2<=n<=26)

sample input:
2

output:
- ab
a b
b a
ab -

I don't understand this at all. What does your sample input mean? Is it that there are just two people? If so then a will go to one room and b to another where they will talk to themselves. What do the space and the dash in your output represent?
Sep 15 '06 #2
D_C
293 100+
Encode the problem using a binary string, and also use recursion.
Suppose n = 6. Then have a six digit binary string, modeled by a six entry boolean array. Then 000000 means all six people are in the first room, 111111 means all six are in the second room. For persons A, C, and D to be in the first room, while B, E, F are in the second, is 010011.

It's 51 lines of code. Of course, I could delete four sets of parenthesis and get it down to 43 lines of code.
Expand|Select|Wrap|Line Numbers
  1. Enter number of people: 4
  2. -       abcd
  3. d       abc
  4. c       abd
  5. cd      ab
  6. b       acd
  7. bd      ac
  8. bc      ad
  9. bcd     a
  10. a       bcd
  11. ad      bc
  12. ac      bd
  13. acd     b
  14. ab      cd
  15. abd     c
  16. abc     d
  17. abcd    -
  18. Press any key to continue . . .
Sep 15 '06 #3
D_C
293 100+
Actually, after thinking about it, recursion is not necessary. It's tail end, so it could be converted to a for loop. Then, you could encode the 2^N possibilities by counting from 0 to (2^N - 1).
Sep 15 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: the_proud_family | last post by:
HELP ME PLEASE!! my email is the_proud_family@yahoo.com I can't get the ball to go up right side and then I need it to turn around and keep turning until velocity=0 I have been at it for the ...
3
by: Jay | last post by:
I previously posted this question under Visual Basic newsgroup, but was advised to re-post here. I'm hoping someone can help me solve an issue I'm having with VB.Net and Access 2000. Here's...
15
by: Holly | last post by:
I'm trying to get this page to look the same in Netscape and IE. I have a box that says 'Upcoming Events' on the lower left of the page. It's supposed to have a gray background, but in NS 4.x it...
12
by: Vibhajha | last post by:
Hi friends, My sister is in great problem , she has this exam of C++ and she is stuck up with some questions, if friends like this group provides some help to her, she will be very grateful....
15
by: Alfonso Morra | last post by:
Hi, I have some code from an example, that I want to retrofit into my project. The code from the example has the following line: SharedAppenderPtr myAppender( new...
1
by: Mohammed Mazid | last post by:
Basically I want to store the answer of a single-choice question (where candidate selects one answer) and multiple-choice question (where candidate selects more than one answer). I would like to...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
1
by: myemail.an | last post by:
Hi all, I am a novice to Access, and was wondering if I could get some help on a problem I can't solve. I have a database with customer payments, structured like this: customer code type of...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.