Question

You're are working on n different projects, but in m hours you are going on vacation....

You're are working on n different projects, but in m hours you are going on vacation. Imagine that for each project i, you had a function fi that told you how happy the people paying for project i would be if out your m available hours you devoted 0 ≤ x ≤ m to project i. Imagine further that each such function has maximum value at most s, corresponding to the project being fully finished (and thus the clients being perfectly happy).

Give a dynamic programming for determining the most happiness you can generate for your clients by splitting your m hours among the n projects.

• Because of book-keeping rules, you can’t spend fractional hours on a project.
• The functions fi are non-decreasing, i.e., for every project i, if t1 ≤ t2, then fi(t1) ≤ fi(t2).
• The running time of your algorithm must be O(nambsc) for some fixed integers a, b, c ≥ 0.

For this problem:

1.Write an identity for the OPT value.

2.Explain why the idenity holds. Your explanation should appear self-evident.

3.Describe the data structure you will use to store the OPT value for the subproblems and the order in which you will fill out the entries in your data structure.

4.In the problems you are asked to return the solution (not just the value of the solution), state the additional information you record which will allow you to retrace your steps and report an optimal solution.

5.Bound the running time by the size of the data structure and the work per entry in it

Homework Answers

Answer #1

The ChainedHashTable data structure uses an array of lists, where the th list stores all elements such that . An alternative, called open addressing is to store the elements directly in an array, , with each array location in storing at most one value. This approach is taken by the LinearHashTable described in this section. In some places, this data structure is described as open addressing with linear probing.

The main idea behind a LinearHashTable is that we would, ideally, like to store the element with hash value in the table location . If we cannot do this (because some element is already stored there) then we try to store it at location ; if that's not possible, then we try , and so on, until we find a place for .

There are three types of entries stored in :

  1. data values: actual values in the USet that we are representing;
  2. values: at array locations where no data has ever been stored; and
  3. values: at array locations where data was once stored but that has since been deleted.

In addition to the counter, , that keeps track of the number of elements in the LinearHashTable, a counter, , keeps track of the number of elements of Types 1 and 3. That is, is equal to plus the number of values in . To make this work efficiently, we need to be considerably larger than , so that there are lots of values in . The operations on a LinearHashTable therefore maintain the invariant that .

To summarize, a LinearHashTable contains an array, , that stores data elements, and integers and that keep track of the number of data elements and non- values of , respectively. Because many hash functions only work for table sizes that are a power of 2, we also keep an integer and maintain the invariant that .

    T[] t;   // the table
    int n;   // the size
    int d;   // t.length = 2^d
    int q;   // number of non-null entries in t

The operation in a LinearHashTable is simple. We start at array entry where and search entries , , , and so on, until we find an index such that, either, , or . In the former case we return . In the latter case, we conclude that is not contained in the hash table and return .

    T find(T x) {
        int i = hash(x);
        while (t[i] != null) {
            if (t[i] != del && x.equals(t[i])) return t[i];
            i = (i == t.length-1) ? 0 : i + 1; // increment i
        }
        return null;
    }

The operation is also fairly easy to implement. After checking that is not already stored in the table (using ), we search , , , and so on, until we find a or and store at that location, increment , and , if appropriate.

    boolean add(T x) {
        if (find(x) != null) return false;
        if (2*(q+1) > t.length) resize(); // max 50% occupancy
        int i = hash(x);
        while (t[i] != null && t[i] != del)
            i = (i == t.length-1) ? 0 : i + 1; // increment i
        if (t[i] == null) q++;
        n++;
        t[i] = x;
        return true;
    }
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Project Management Fundamentals Questions Only A project team is discussing the benefits and drawbacks of working...
Project Management Fundamentals Questions Only A project team is discussing the benefits and drawbacks of working on projects within their organization now that it has become project-oriented. They can agree on many advantages for the team and for the organization, but also agree there are some drawbacks, relative to the strong matrix structure the organization used to have. In a project-oriented organization the project team: ANSWER Will not always have a "home" Reports to the functional manager Has no loyalty...
Summary The Ch08_ConstructCo database stores data for a consulting company that tracks all charges to projects....
Summary The Ch08_ConstructCo database stores data for a consulting company that tracks all charges to projects. The charges are based on the hours each employee works on each project. The structure and contents of the Ch08_ConstructCo database are shown in Figure P8.1. Use this database to answer the following problems. Database Schema The schema for the Ch08_ConstructCo database is shown below and should be used to answer the next several problems. Click this image to view it in its own...
1.) You will work with 0.10 M acetic acid and 17 M acetic acid in this...
1.) You will work with 0.10 M acetic acid and 17 M acetic acid in this experiment. What is the relationship between concentration and ionization? Explain the reason for this relationship 2.) Explain hydrolysis, i.e, what types of molecules undergo hydrolysis (be specific) and show equations for reactions of acid, base, and salt hydrolysis not used as examples in the introduction to this experiment 3.) In Part C: Hydrolysis of Salts, you will calibrate the pH probe prior to testing...
Performance Evaluation Who are you? You are a team leader at Anders Consulting, a small but...
Performance Evaluation Who are you? You are a team leader at Anders Consulting, a small but growing strategy consulting firm in Atlanta. For a little over three months, you have been supervising a team of junior-level management consultants, who just finished developing a strategic plan with a division of RGP Financial Services. What's the current situation? The work you have supervised has involved a variety of research, interviewing, writing, and speaking activities. Part of your job as team leader is...
Rosa Lee and Scott Bradshaw are facing an important decision. After having discussed different financial scenarios...
Rosa Lee and Scott Bradshaw are facing an important decision. After having discussed different financial scenarios into the wee hours of the morning, the two computer engineers felt it was time to finalize their cash flow projections and move to the next stage – decide which of two possible projects they should undertake. Both had a bachelor degree in engineering and had put in several years as maintenance engineers in a large chip manufacturing company. About six months ago, they...
Assignment: What are the main arguments in the article? Please answer within 5 hours. It is...
Assignment: What are the main arguments in the article? Please answer within 5 hours. It is extremely urgent!!!!!!!!!!!!!!!!!!!!!!!! --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- BIOETHICS. Bioethics as a field is relatively new, emerging only in the late 1960s, though many of the questions it addresses are as old as medicine itself. When Hippocrates wrote his now famous dictum Primum non nocere (First, do no harm), he was grappling with one of the core issues still facing human medicine, namely, the role and duty of the...
What topics are covered in the following article? Please answer within 5 hours. It is extremely...
What topics are covered in the following article? Please answer within 5 hours. It is extremely urgent!!!!!!!!!!!!!!!!!!!!!!!! --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- BIOETHICS. Bioethics as a field is relatively new, emerging only in the late 1960s, though many of the questions it addresses are as old as medicine itself. When Hippocrates wrote his now famous dictum Primum non nocere (First, do no harm), he was grappling with one of the core issues still facing human medicine, namely, the role and duty of the physician....
** Summarize the following paragraphs in ONE PARAGRAPH please.** Just as my deadline approached for the...
** Summarize the following paragraphs in ONE PARAGRAPH please.** Just as my deadline approached for the editorial for this issue, Time magazine for March 5, 2018 arrived at my home. In this historic issue, entirely devoted to the topic of the opioid epidemic in the United States, riveting black and white photographs by James Nachtwey depict what is happening in my country. It is difficult for me to find words to describe the emotional impact of these photographs, even though...
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation....
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation. case:    W17400 APIGEE: PEOPLE MANAGEMENT PRACTICES AND THE CHALLENGE OF GROWTH Ranjeet Nambudiri, S. Ramnarayan, and Catherine Xavier wrote this case solely to provide material for class discussion. The authors do not intend to illustrate either effective or ineffective handling of a managerial situation. The authors may have disguised certain names and other identifying information to protect confidentiality. This publication may not be...
provide 3-4 paragraphs post (team 2) 1-What are 4 key things you learned about the topic...
provide 3-4 paragraphs post (team 2) 1-What are 4 key things you learned about the topic from reading their paper? 2-How does the topic relate to you and your current or past job? 3-Critique the paper in terms of the organization and quality.1- Employee Stress and how it has an Adverse Effect on a Company This paper explores employee stress and how it has an adverse effect on a company, its employees and the organization. Job stress can have a...