473,395 Members | 2,222 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,395 software developers and data experts.

Write a function using Recursion to do the following

Write a function using Recursion to do the following: You are the manager in a small factory. You have 7 workers and 7 jobs to be done. Each worker is assigned one and only one job. Each worker demands different pay for each job. (E.g.: Worker Archie demands $10 for welding, $15 for carpentry, etc. Worker Jughead demands $12 for welding, $5 for carpentry, etc.) Find the job-assignment which works out cheapest for you.
Nov 23 '07 #1
4 1542
DumRat
93
Have you tried doing it? Post where exactly you are having trouble. No one will write the code for you.
Nov 23 '07 #2
amitpatel66
2,367 Expert 2GB
Hi Nithiya Kalyani,

Welcome to TSDN

Please make sure you follow POSTING GUIDELINES when ever you post in this forum.

MODERATOR
Nov 23 '07 #3
amitpatel66
2,367 Expert 2GB
Write a function using Recursion to do the following: You are the manager in a small factory. You have 7 workers and 7 jobs to be done. Each worker is assigned one and only one job. Each worker demands different pay for each job. (E.g.: Worker Archie demands $10 for welding, $15 for carpentry, etc. Worker Jughead demands $12 for welding, $5 for carpentry, etc.) Find the job-assignment which works out cheapest for you.
Please post the following,

1. Where is the data actually stored? Which databse you are using to store this data?
2. Is it mandatory to write a recursive function for this?
3. What you have tried to achieve this?
Nov 23 '07 #4
JosAH
11,448 Expert 8TB
Draw a 7x7 grid; the columns represent the workers, the rows represent the jobs.
The individual cells c_ij represent the cost when job i is done by worker j.

You have to mark one cell per column and per row such that the sum of the marked
c_ij is minimal.

Let a_ij in [0, 1] be an integer variable such that a_ij == 1 when job j is performed
by worker j, and 0 otherwise. So you have to minimize the following formula:

sum(i, j in [1, 7] | a_ij*c_ij). w.r.t. the constraints:
sum(i in [1, 7] | a_ij == 7) and
sum(j in [1, 7] | a_ij == 7).

This indeed is the classical "job assignment problem" which happens to be the
smallest class of problems in the MNCF ("Minimal Cost Network Flow") problems
and can be easily solved with a network simplex algorithm.

Solving it recursively is ludirous because it can be highly inefficient. The brutest
force method of them all is to iterate over the 7! possibilities and pick the cheapest.

kind regards,

Jos
Nov 23 '07 #5

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

Similar topics

25
by: James Harlacher | last post by:
Hi, Are there any C compilers which have the erf function (from probability) as part of their math libraries? Or are there any math libraries available to download which implement this function?...
23
by: I.M. !Knuth | last post by:
A while back, I was mucking around with a recursive function. For brevity's sake, I'll define it like this: int func_recurs(int arg1, int arg2, int prev_pos) { int crnt_pos = 0; int result; ...
7
by: sam_cit | last post by:
Hi Everyone, I have a function declared as inline and i was wondering as to how it would be expanded by the compiler sample(int x) { if (x>0) sample(--x); printf("%d",x); }
14
by: subramanian100in | last post by:
In the following link, http://www.c-faq.com/malloc/retaggr.html The following ANSWER is given to a question(comp.lang.c FAQ list · Question 7.5a) : Whenever a function returns a pointer, make...
13
by: JD | last post by:
Hi, My associate has written a copy constructor for a class. Now I need to add an operator = to the class. Is there a way to do it without change her code (copy constructor) at all? Your help...
12
by: Tom_chicollegeboy | last post by:
here is what I have to do: This question involves a game with teddy bears. The game starts when I give you some bears. You then start giving me back some bears, but you must follow these rules...
1
by: George2 | last post by:
Hello everyone, Such code segment is used to check whether function call or exception- handling mechanism runs out of memory first (written by Bjarne), void perverted() { try{
9
by: pereges | last post by:
Hello I need some ideas for designing a recursive function for my ray tracing program. The idea behind ray tracing is to follow the electromagnetic rays from the source, as they hit the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.