Implement a priority queue using a DoublyLinkedList where the
node with the highest priority (key) is the right-most node.
The remove (de-queue) operation returns the node with the highest
priority (key).
If displayForward() displays List (first-->last) : 10 30 40
55
remove() would return the node with key 55.
Demonstrate by inserting keys at random, displayForward(), call
remove then displayForward() again.
You will then attach a modified DoublyLinkedList.java (to
contain the new priorityInsert(long key) and priorityRemove()
methods).
Use the provided PQDoublyLinkedTest.java to test your code.
I cant get PQDoublyLinkedTest to work with my code. I already got the rest of code working. Please comment if you want me to add the rest of the code.
PLEASE DO NOT MODIFY PQDoublyLinkedTest!!! its just for testing the code.
public class PQDoublyLinkedTest
{
public static void main(String[] args)
{ // make a new list
DoublyLinkedList theList = new DoublyLinkedList();
theList.priorityInsert(22); // insert at front
theList.priorityInsert(44);
theList.priorityInsert(66);
theList.priorityInsert(11); // insert at rear
theList.priorityInsert(33);
theList.priorityInsert(55);
theList.priorityInsert(10);
theList.priorityInsert(70);
theList.priorityInsert(30);
theList.displayForward(); // display list forward
Link2 removed = theList.priorityRemove();
System.out.print("priorityRemove() returned node with key:
");
removed.displayLink2();
} // end main()
} // end class PQDoublyLinkedTest
public class DoublyLinkedList
{
private Link first; // ref to first item
private Link last; // ref to last item
public DoublyLinkedList() // constructor
{
first = null; // no items on list yet
last = null;
}
public boolean isEmpty() // true if no links
{
return first == null;
}
public void insertFirst(long dd) // insert at front of
list
{
Link newLink = new Link(dd); // make new link
if (isEmpty()) // if empty list,
last = newLink; // newLink <-- last
else
first.previous = newLink; // newLink <-- old first
newLink.next = first; // newLink --> old first
first = newLink; // first --> newLink
}
public void insertLast(long dd) // insert at end of list
{
Link newLink = new Link(dd); // make new link
if (isEmpty()) // if empty list,
first = newLink; // first --> newLink
else {
last.next = newLink; // old last --> newLink
newLink.previous = last; // old last <-- newLink
}
last = newLink; // newLink <-- last
}
public Link deleteFirst() // delete first link
{ // (assumes non-empty list)
Link temp = first;
if (first.next == null) // if only one item
last = null; // null <-- last
else
first.next.previous = null; // null <-- old next
first = first.next; // first --> old next
return temp;
}
public Link deleteLast() // delete last link
{ // (assumes non-empty list)
Link temp = last;
if (first.next == null) // if only one item
first = null; // first --> null
else
last.previous.next = null; // old previous --> null
last = last.previous; // old previous <-- last
return temp;
}
// insert dd just after key
public boolean insertAfter(long key, long dd)
{ // (assumes non-empty list)
Link current = first; // start at beginning
while (current.dData != key) // until match is found,
{
current = current.next; // move to next link
if (current == null)
return false; // didn't find it
}
Link newLink = new Link(dd); // make new link
if (current == last) // if last link,
{
newLink.next = null; // newLink --> null
last = newLink; // newLink <-- last
} else // not last link,
{
newLink.next = current.next; // newLink --> old next
// newLink <-- old next
current.next.previous = newLink;
}
newLink.previous = current; // old current <-- newLink
current.next = newLink; // old current --> newLink
return true; // found it, did insertion
}
public Link deleteKey(long key) // delete item w/ given
key
{ // (assumes non-empty list)
Link current = first; // start at beginning
while (current.dData != key) // until match is found,
{
current = current.next; // move to next link
if (current == null)
return null; // didn't find it
}
if (current == first) // found it; first item?
first = current.next; // first --> old next
else
// not first
// old previous --> old next
current.previous.next = current.next;
if (current == last) // last item?
last = current.previous; // old previous <-- last
else
// not last
// old previous <-- old next
current.next.previous = current.previous;
return current; // return value
}
public void displayForward()
{
System.out.print("List (first-->last): ");
Link current = first; // start at beginning
while (current != null) // until end of list,
{
current.displayLink(); // display data
current = current.next; // move to next link
}
System.out.println("");
}
public void displayBackward()
{
System.out.print("List (last-->first): ");
Link current = last; // start at end
while (current != null) // until start of list,
{
current.displayLink(); // display data
current = current.previous; // move to previous link
}
System.out.println("");
}
public void insertSorted(long key)
{
// if list is empty or key is less than current first, inserting
at
// first
if (isEmpty() || key < first.dData) {
insertFirst(key);
return; // exiting method
}
// taking a reference to first
Link current = first;
// looping as long as current.next is not null
while (current.next != null) {
// checking if key can be added between current and
current.next
if (key >= current.dData && key <=
current.next.dData) {
// adding between current and current.next and updating all
// links
Link lnk = new Link(key);
lnk.next = current.next;
current.next.previous = lnk;
current.next = lnk;
lnk.previous = current;
return; //exiting
}
//otherwise, advancing to next link
current = current.next;
}
//if the element is still not inserted, adding to the end
insertLast(key);
}
} // end class DoublyLinkedList
class Link
{
public long dData; // data item
public Link next; // next link in list
public Link previous; // previous link in list
public Link(long d) // constructor
{
dData = d;
}
public void displayLink() // display this link
{
System.out.print(dData + " ");
}
} // end class Link
In: Computer Science
A company wants to study the relationship between an employee's length of employment and their number of workdays absent. The company collected the following information on a random sample of seven employees.
|
Number of Workdays Absent |
2 |
3 |
3 |
5 |
7 |
7 |
8 |
|
Length of Employment (in yrs) |
5 |
6 |
9 |
4 |
2 |
2 |
0 |
5.What is the least squares equation for the data?
6.What is the meaning of a negative slope?
7.What is the standard error of estimate?
In: Statistics and Probability
Steve Rogers recently started a job as an administrative assistant in the cost accounting department of Mickey Manufacturing . New to the area of cost accounting , Steve is puzzled by the fact that one of Mickey ' s manufactured products , R2D2 , seems to have a different cost , depending on who asks for it . When the marketing department requested the cost of R2D2 in order to determine pricing for the new catalog , Steve was told to report one amount , but when a request came in the very next day from the financial reporting department , the cost of R2D2 , she was told the cost was very different . Steve runs a report using Mickey ' s cost accounting system , which produces the following cost elements for one unit of R2D2 . Direct Materials Direct Manufacturing Labor Variable Manufacturing Overhead Allocated Fixed Manufacturing Overhead Research and development costs specific to RCP10 * Marketing Costs * Sales Commissions * Allocated administrative costs of production department Allocated administrative costs of corporate headquarters Customer Service costs * Distribution costs * $ 30 . 00 $ 17 . 00 $ 9 . 00 $ 33 . 00 $ 6 . 00 $ 7 . 00 $ 12 . 00 $ 5 . 00 $ 18 . 00 $ 3 . 00 $ 9 . 00 * these costs are specific to R2D2 but would not be eliminated if R2D2 were purchased from an outside supplier . Required : 1 . Explain to Steve why the costs given to the marketing and financial reporting departments would be different . 2 . Calculate the cost of one unit of RCP10 to determine the following : a . The selling price of RCP10 b . The cost of inventory for financial reporting c . The ability of Mickey ' s production manager to control costs .
In: Accounting
1) A workman's wage for a guaranteed 44 week is Rs.
0.19 per hour. The week time produce of
one article is 30 minutes and under incentive scheme
the time allowed is increased by 20%.
During one week the workman manufactured 100 articles. Calculate
his gross wages under
each of the following methods of remuneration:
a. Time rate b. Piece work with a guaranteed weekly wage c. Rowan
premium bonus
d. Halsey premium bonus, 50% to workman
In: Accounting
Case Study 2: The Turn Around at Ford Ford has been going through difficult times and recovered more than once. The company’s share of the automobile market continues to shrink, and its cost structure has contributed to financial losses. In 2006, Ford lost $12.6 billion. In 2007, Ford did better, posting losses of only $2.7 billion. At the same time, however, Ford’s market shares dwindled and in 2007, its share was 14.8%—down from 26% in the 1990s. In an effort to match its production with the demand for its products, as well as address concerns with its high labor costs, Ford has focused on trying to get smaller to achieve long-term success in the automobile industry. One of the primary ways for Ford to achieve this goal is to take further steps to reduce the size of its workforce. Ford’s workforce went from 283,000 employees in 2006 to 171,000 in 2013. Ford then announced a new round of buyouts and early-retirement packages to its workers in an effort to cut costs and replace those leaving with lower-paid workers. Some of the offers made to reduce the labor supply in 2013 included: Workers who were eligible for retirement would receive a $50,000 offer, higher than the $35,000 in the previous round of buyouts. Skilled-trade workers, such as maintenance workers, will get an additional $20,000, bringing the total potential payout for such a worker to $70,000. Following the 2013 round of buyouts, Ford extended its tactics to reduce the size of its workforce and ongoing expenses further through means such as the following: Extending a buyout option for its 78,000 employees and special incentives for its 40,800 workers who are eligible for retirement to retire sooner rather than later. Offering a lump sum payment for 90,000 retired engineers and office workers to forgo their regular monthly pension check for the rest of their lives. The automaker’s goal in offering the company-wide buyouts was to cut jobs, reduce its ongoing pension expenses, to position itself to be more competitive in the market, and to align its labor capacity with the demand for its products. In 2018, Ford announced that by 2020 around 90% of Ford’s sales in North America would be trucks, SUVs and commercial vehicles. The only two cars to be manufactured in North America would be the Mustang and the Focus Active Crossover. The company has reallocated $7 billion of its research funds from cars to trucks and SUVs.
Questions
What factors have contributed to the large-scale labor surplus at Ford?
What impact is the most recent strategic plan at Ford likely to have on the company’s labor supply?
Over the years, Ford has decided to pursue employee buyouts and attrition in an attempt to shrink its workforce to match its productivity demands. Why do you think Ford uses these two tactics? Do you think these are the best options for Ford to achieve its goals?
What are the downsides of these two approaches? Are there any other approaches you might recommend addressing its labor surplus?
In: Operations Management
A researcher surveyed 12 men who lost their fathers earlier in their lives. His survey included the age of the subjects when their fathers died and their confidence that they would someday be happily married themselves (100 point scale – higher score = more confidence). The results are shown below.
Mx=15 My =60
SSx=348 SSy=5198
SPxy=933
| Age | Confidence Rating |
| 12 | 34 |
| 8 | 30 |
| 11 | 89 |
| 21 | 69 |
| 15 | 55 |
| 7 | 38 |
| 18 | 78 |
| 23 | 66 |
| 22 | 89 |
| 19 | 79 |
| 9 | 35 |
| 15 | 58 |
Can you estimate a confidence rating for a man who lost his father at 30 years old? Why or why not?
In: Statistics and Probability
1. An ecologist is interested in studying the presence of different types of animal species in different locations. Using the following contingency table and the total sample size, rewrite the frequencies as relative frequencies. Round each relative frequency to two decimal places.
| Location | bird species | mammal species | fish species |
| A | 21 | 4 | 6 |
| B | 16 | 2 | 0 |
| C | 3 | 1 | 7 |
| Location | bird species | mammal species | fish species |
| A | |||
| B | |||
| C |
2. You are interested in learning about students' favorite mode of transportation at two universities. Fill in the blanks in the following contingency table, assuming that the variables are independent.
| University | Bike | Car | Bus | Train | Other | Total |
| A | 592 | 300 | 204 | 80 | 1202 | |
| B | 410 | 335 | 20 | 55 | 1010 | |
| Total | 1002 | 635 | 394 | 44 | 135 | 2212 |
3.Your teacher claims that the final grades in class are distributed as: A, 25%; B, 25%; C, 40%; D, 5%; F, 5%. At the end of a randomly selected academic quarter, the following number of grades are recorded. Calculate the appropriate chi-square test statistic that would be used to determine if the grade distribution for the course is different than expected. Round your answer to two decimal places.
| Grade | A | B | C | D | F |
| Number | 36 | 42 | 58 | 10 | 14 |
4. A dog breeder wishes to see if prospective dog owners have any preference among six different breeds of dog. A sample of 200 people (prospective dog owners) provided the data below. Find the critical chi-square value that would be used to test the claim that the distribution is uniform. Use α = 0.01 and round your answer to three decimal places.
| Breed | 1 | 2 | 3 | 4 | 5 | 6 |
| People | 35 | 27 | 45 | 40 | 28 | 25 |
In: Math
Simon Inc. is making the daily brownie run across the Chicago metropolitan area. They have seven customers and have identified the driving distance (in miles) between each pairwise combination as shown in the table. One-way streets and various construction projects affect driving distances such that the distance from one to the other may not be same depending on which site is the starting point. Identify the most energy efficient route that begins at Simon Inc. headquarters (Simon) and visits each customer once before returning to headquarters. Show work
| From/To | Simon | Bosco's | Champion | Damron | Enumclaw | Luther | Jones | Emily |
| Simon | 0 | 9 | 97 | 17 | 22 | 34 | 55 | 71 |
| Bosco's | 14 | 0 | 99 | 29 | 20 | 39 | 84 | 53 |
| Champion | 63 | 8 | 0 | 90 | 96 | 89 | 66 | 78 |
| Damron | 98 | 90 | 29 | 0 | 46 | 88 | 62 | 13 |
| Enumclaw | 27 | 88 | 94 | 81 | 0 | 49 | 53 | 35 |
| Luther | 91 | 95 | 62 | 91 | 19 | 0 | 73 | 91 |
| Jones | 87 | 2 | 27 | 69 | 11 | 4 | 0 | 25 |
| Emily | 61 | 31 | 58 | 13 | 15 | 92 | 44 | 0 |
In: Operations Management
14. Explain the possible consequences of not using the degrees of freedom when calculating the sample standard deviation?
16. A researcher tested two groups (females and males) of rats on memory performance. The following scores are for the number of correct choices they made on the task:
Females
Males
9
8
7
6
7
8
8
6
9
7
8
6
9
9
9
6
Calculate the standard deviation for each group.
Which group shows more variability in their memory
scores?
18. Using the Empirical Rule how much of the population is found in the 1st, 2nd and 3rd standard deviation?
In: Statistics and Probability
Finishing Touches has two classes of stock authorized: 8%, $10 par preferred, and $1 par value common. The following transactions affect stockholders’ equity during 2018, its first year of operations:
January 2 Issues 100,000 shares of common stock for $34 per share.
February 6 Issues 2,900 shares of 8% preferred stock for $12 per share.
September 10 Repurchases 10,000 shares of its own common stock for $39 per share.
December 15 Reissues 5,000 shares of treasury stock at $44 per share.
Required:
Record each of these transactions. (If no entry is required for a transaction/event, select "No journal entry required" in the first account field.)
In: Accounting