C++:
Do not change anything in the supplied code
below that will be the Ch16_Ex5_MainProgram.cpp
except to add documentation. PLEASE DO NOT CHANGE
THE CODE JUST ADD DOCUMENTATION. Thank you. The last few have
changed the code. Appreciate you all.
Please use the file names listed below since your file will have
the following components:
Ch16_Ex5_MainProgram.cpp - given file
//22 34 56 4 19 2 89 90 0 14 32 88 125 56 11 43 55 -999
#include <iostream>
#include "unorderedLinkedList.h"
using namespace std;
int main()
{
unorderedLinkedList<int> list, subList;
int num;
cout << "Enter numbers ending with -999" <<
endl;
cin >>
num;
while (num !=
-999)
{
list.insertLast(num);
cin >>
num;
}
cout << endl;
cout << "List:
";
list.print();
cout <<
endl;
cout << "Length of the list: " << list.length()
<<
endl;
list.divideMid(subList);
cout << "Lists after splitting list" << endl;
cout << "list: ";
list.print();
cout <<
endl;
cout << "Length of the list: " << list.length()
<<
endl;
cout << "sublist: ";
subList.print();
cout <<
endl;
cout << "Length of subList: " << subList.length()
<< endl;
system("pause");
return
0;
}
linkedList.h
unorderedLinkedList.h
In: Computer Science
Nodes Problems
In C++,
Your objective is to write the definition of the function Maximum() whose header is double Maximum(Node* root) It returns the maximum value from the singly linked list referenced by root. If root is referencing an empty list, the function returns 0.
Part B: Take home Your objective is to write the definition of the following functions the function
EndAppend() whose header is void EndAppend(Node*& data,Node* addon) template It appends the linked list referenced by addon to the end of the linked list referenced by data. For instances, if data = [a, b, c, d, e] and addon = [f, g, h, i, j]; then after the call of the function, data = [a, b, c, d, e, f, g, h, i, j].
the function GreaterThan() whose header is bool GreaterThan(Node* op1,Node* op2). Given that op1 and op2 references doubly linked lists that represent binary numbers, the function returns true if the list referenced by op1 is greater than the list referenced by op2 . For instances, if op1 = [0, 0, 1, 1, 0] and op2 = [1, 0, 0, 1], the function will return false. Do not assume that the lists are the same size.
In: Computer Science
Create a class called College that has:
Write two unsorted lists that manage the data for colleges and their ranking:
Each college will have a unique ID number that will be used for search.
For the lab you don't need to read the commands from a file. Your commands will be hard-coded as function calls within your main() function.
The following actions will be performed twice: once with the array and once with the linked list. Make sure your code is clearly marked with comments, so the grader can easily see which actions were performed with each structure.
C++language
In: Computer Science
(Programming Language: Python)
It's trivial that the value of a number remains the same no matter how many zeros precede it. However, adding the zeros at the end of the number increases the value * 10. Jasmine is tired of seeing \001/100" on her tests (well yes, no one really writes 001, but Jasmine's teacher finds it funny to do so). So, she managed to login to her teacher's computer and now wants to design a function that can move the 0's in her grade to the end before her teacher uploads her grades. Although we don't agree with Jasmine's tactics, Krish (Jasmine's mentor) told us to help her out by finishing the `move zeros' function. This function should move all the 0's in the given list to the end while preserving the order of the other elements.
Remember that this function needs to modify the list, not return a new list!
---------------------------------------------
def move_zeros(lst: List[int]) -> None:
"""
Move all the 0's in lst to the END of the lst *in-place*, i.e. *modify* the list, DONT return a new list
>>> lst = [1, 0, 2, 3]
>>> move_zeros(lst)
>>> lst [1, 2, 3, 0]
"""
pass
In: Computer Science
Suppose a professor has 3 separate lists of questions totaling 120 questions including:
List 1: includes 35 “Hard” questions. You have 40% likelihood of answering each hard question correctly
List 2: includes 50 “Intermediate” questions. You have 60% likelihood of answering each intermediate question correctly
List 3: includes 35 “Easy” questions. You have 80% likelihood of answering each easy question correctly
Professor lets you choose either one of the following 5 exams (You take only one of these 5):
Exam1: includes 30 randomly selected questions, all from list 1. If you choose this exam you can pass if you score 40% (12 out of 30) or higher in this exam.
Exam2: includes 30 randomly selected questions, all from list 2. If you choose this exam you can pass if you score 60% (18 out of 30) or higher in this exam.
Exam3: includes 30 randomly selected questions, all from list 3. If you choose this exam you can pass if you score 80% (24 out of 30) or higher in this exam.
Exam4: including 30 questions that consist of 7 questions from the list 1, 13 questions from the list 2, and 10 questions from list 3 (all randomly selected). If you choose this exam you can pass if you score 60% (18 out of 30) or higher in this exam.
Exam5: includes 30 randomly selected questions from the list of all 120 questions of all 3 lists combined. If you choose this exam you can pass if you score 60% (18 out of 30) or higher in this exam.
Find probability of passing each exam i.e. fill out the empty column in the following table based on binomial distribution answers and highlight in the table the exam which you will choose to take. (Do not use binomial to Normal approximation for question 1, just solve it as binomial)
***Needs to be solved as Binomial***
|
P(passing the exam1) |
|
P(passing the exam2) |
|
P(passing the exam3) |
|
P(passing the exam4) |
|
P(passing the exam5) |
In: Statistics and Probability
In this problem, you will write a program that reverses a linked
list. Your program should take as input a space-separated list of integers
representing the original list, and output a space-separated list of integers
representing the reversed list. Your algorithm must have a worst-case run-
time in O(n) and a worst-case space complexity of O(1) beyond the input.
For example, if our input is:
5 7 1 2 3
then we should print:
3 2 1 7 5
Please note that the starter code contains the following files:
• MyLinkedListNode: A class representing linked list nodes. Each
node contains an integer value, a variable next representing the next
node in the list (which is null if we’re at the last node), and a variable prev
representing the previous node in the list (which is null if we’re at the first node). You will probably need to modify this file.
• MyLinkedList: A class representing a stripped-down version of a
linked list. We keep track of the first and last nodes of the list, and
have methods for creating linked lists from arrays and converting
linked lists to space-separated strings.
Your task is to complete the reverse() method in this class.
• Main: A class with a main() method that collects input into a linked
list, calls the reverse() method, and outputs the resulting linked
list. You should not modify this file.
Restrictions:
(a) In this problem, you must use the custom MyLinkedList class. You may not use the normal LinkedList class. Any solutions that do not use MyLinkedList will receive a zero in all categories.
(b) Your algorithm must have a worst-case runtime in O(n) and a worst-
case space complexity of O (1) beyond the input. Any solutions that are less efficient will receive at most half credit for all categories. The class Main provides starter code for turning the input into a linked list, and turning a linked list into the output string. Your job is to implement the reverse() method in the MyLinkedList class. You will need to modify the MyLinkedListNode class as well.
Main.java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Read in the list of numbers
int[] numbers;
String input = sc.nextLine();
if (input.equals("")) {
numbers = new int[0];
} else {
String[] numberStrings = input.split(" ");
numbers = new int[numberStrings.length];
for (int i = 0; i < numberStrings.length; i++) {
numbers[i] = Integer.parseInt(numberStrings[i]);
}
}
// Create a MyLinkedList containing these numbers
MyLinkedList numbersList = new MyLinkedList(numbers);
// Reverse the list
numbersList.reverse();
// Print the reversed list
System.out.println(numbersList.toString());
}
}
MyLinkedList.java
public class MyLinkedList {
private MyLinkedListNode firstNode = null;
private MyLinkedListNode lastNode = null;
private int length = 0;
/**
* Constructs a MyLinkedList from an integer array.
*/
public MyLinkedList(int[] numbersArray) {
// set length
length = numbersArray.length;
// leave the first and last nodes as null if there
// are no elements in the array
if (numbersArray.length == 0) {
return;
}
// set the first node to the first number
firstNode = new MyLinkedListNode(numbersArray[0], null,
null);
if (numbersArray.length == 1) {
lastNode = firstNode;
return;
}
// create all the middle nodes
MyLinkedListNode prevNode = firstNode;
for (int i = 1; i < numbersArray.length - 1; i++) {
MyLinkedListNode currentNode =
new MyLinkedListNode(numbersArray[i], prevNode, null);
prevNode.setNext(currentNode);
prevNode = currentNode;
}
// set the last node to the last number
lastNode = new MyLinkedListNode(
numbersArray[numbersArray.length-1],
prevNode,
null);
prevNode.setNext(lastNode);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(length);
MyLinkedListNode currentNode = firstNode;
for (int i = 0; i < length; i++) {
sb.append(currentNode.toString());
if (i < length - 1) {
sb.append(" ");
currentNode = currentNode.getNext();
}
}
return sb.toString();
}
/**
* Reverses this linked list.
*/
public void reverse() {
// TODO implement this
}
}
MyLinkedListNode.java
public class MyLinkedListNode {
private int value = 0;
private MyLinkedListNode prev = null;
private MyLinkedListNode next = null;
public MyLinkedListNode(int value, MyLinkedListNode prev,
MyLinkedListNode next) {
this.value = value;
this.prev = prev;
this.next = next;
}
public MyLinkedListNode getNext() {
return next;
}
public void setNext(MyLinkedListNode next) {
this.next = next;
}
@Override
public String toString() {
return (new Integer(this.value)).toString();
}
}
In: Computer Science
We discussed some of the theoretical aspects of the social discount rate (r) in class. The benchmark for cost-bene t analysis by the public sector was set by the O ce of Management & Budget (OMB) in 1992 to 7%. However, Obama's Council of Economic Advisers questioned this (see the policy paper posted under additional reading). In the 1970s, the OMB used 10%, and then lowered it in the 1980s to 8%. In the 1950s, the Army Corps of Engineers used a discount rate of 2.5%.
In 1965, the economist Kenneth Boulding testi ed before the Congressional Subcommittee on Irrigation & Reclamation and recited a poem regarding the issue:
The long-term interest rate
Determines any project's fate:
At 2 percent the case is clear,
At 3 percent some sneaking doubts appear, At 4 percent it draws its
nal breath, While 5 percent is certain death.
4
Boulding's lyrics suggest that the discount rate (r) a ects whether a project will be approved that is, whether P V (B) > P V (C) or not. Answer the following questions about the discount rate and its a ects on cost-bene t calculations.
(a) Consider a project that costs $12 million initially, but then after 10 years (t = 10), it has a (one-time) bene t of $24 million. Use three of the above-mentioned discount factors 2.5%, 7%, and 10% to demonstrate Boulding's point. Under which discount factors would the project be approved?
(b) Since the costs of projects are typically incurred in the earlier years of a project (while the bene ts typically last into the future), how might an increase in the discount rate a ect NPV calculations? Demonstrate your reasoning using the project values in Table 2 and the three discount rates used in the previous question (2.5%, 7%, and 10%). How do the P V (B) and P V (C) change with over the three di erent discount rates?
Table 2: Project Costs and Benefits
(c) As noted in class, the bene t-cost B/C ratio is really the ratio (PV (B)/PV (C)). When it is greater than 1, NPV > 0. There is an easily deciphered relationship between the internal rate of return (IRR) and the B/C ratio when the PV(B) is a perpetuity. In the case where PV(B) is a perpetuity, the bene t amount (B) is constant each year and continues inde nitely. (It is used frequently in examples in the textbook.) The perpetuity formulation is P V (B) = (B/r). Since the IRR is the discount rate (r) that makes PV (B) = PV (C), we can say that the IRR is when
0 = (B/r)?PV(C) = (B/IRR)?PV(C)
What is the IRR for the project described by Table 2? What is the
value of the B/C
ratio if the discount rate (r) is equal to the IRR?
In: Economics
Suppose you throw a ball into the air. Do you think it takes longer to reach its maximum height or to fall back to earth from its maximum height? We will solve the problem in this project, but before getting started, think about that situation and make a guess based on your physical intuition. 1. A ball with mass m is projected vertically upward from the earth’s surface with a positive initial velocity v0. We assume the forces acting on the ball are the force of gravity and a retarding force of air resistance with direction opposite to the direction of motion and with magnitude p|v(t)|, where p is a positive constant and v(t) is the velocity of the ball at time t. In both the ascent and the descent, the total force acting on the ball is pv mg. (During ascent, v(t) is positive and the resistance acts downward; during descent, v(t) is negative and the resistance acts upward.) So, by Newton’s Second Law, the equation of motion is mv0 = pv mg Solve this di↵erential equation to show that the velocity is v(t) = ✓ v0 + mg p ◆ ept/m mg p 2. Show that the height of the ball, until it hits the ground, is y(t) = ✓ v0 + mg p ◆ m p ⇣ 1 ept/m⌘ mgt p 3. Let t1 be the time that the ball takes to reach its maximum height. Show that t1 = m p ln ✓mg + pv0 mg ◆ Find this time for a ball with mass 1 kg and initial velocity 20 m/s. Assume the air resistance is 1 10 of the speed. 1 4. Let t2 be the time at which the ball falls back to earth. For the particular ball in Problem 3, estimate t2 by using a graph of the height function y(t). Which is faster, going up or coming down? 5. In general, it’s not east to find t2 because it’s impossible to solve the equation y(t)=0 explicitly. We can, however, use an indirect method to determine whether ascent or descent is faster: We determine whether y(2t1) is positive or negative. Show that y(2t1) = m2g p2 ✓ x 1 x 2 ln x ◆ where x = ept1/m. Then show that x > 1 and the function f(x) = x 1 x 2 ln x is increasing for x > 1. Use this result to decide whether y(2t1) is positive or negative. What can you conclude? Is ascent or descent faster?
Please answer #3
Please restate the problem to be solved, and define all variables and parameters. Please explain your reasoning and strategy for solving the problem. Please go over basic principals or key processes underlying the problem that was addressed in the paper. Please include an interpretation of the information in the context in which the problem was solved. Please state your conclusions in complete sentences which stand on their own
Sorry, I know this is a lot
In: Physics
1. Assume that a company has two cost drivers—number of courses and number of students. The planned number of courses and students were 5 and 100, respectively. The actual number of courses and students were 6 and 110, respectively. One of the company’s expenses is influenced by both cost drivers and it has a fixed element as well. Its cost formulas are $50 per course, $5 per student, and $1,000 per period. The total actual amount of this expense is $1,880. The spending variance for this expense would be:
a. 30 U
b. $30 F
c. $130 F
d. $130 U
2. Assume that a
company provided the following cost formulas for three of its
expenses (where q refers to the number of hours
worked):
| Rent (fixed) | $3,000 | ||
| Supplies (variable) | $4.00q | ||
| Utilities (mixed) | $150 + $0.75q | ||
The company’s planned level of activity was 2,000 hours and its
actual level of activity was 1,900 hours. If these are the
company’s only three expenses, what total amount of expense would
appear in the company’s flexible budget?
a. $12025
b. $12175
c. $12650
d. $12250
In: Accounting
A professor has noticed that, even though attendance is not a component of the final grade for the class, students that attend regularly generally get better grades. In fact, 48% of those who come to class on a regular basis receive A's. Only 6% who do not attend regularly get A's. Overall, 60% of students attend regularly. Based on this class profile, suppose we are randomly selecting a single student from this class, and answer the questions below.
Hint #1: pretend that there are 1000 students in the class and use the values given in the problem to construct the appropriate contingency table. Round cell frequencies to the nearest integer
Hint #2: No joke, you really need to use hint #1.
Hint #3: The first step to using hint #1 is to calculate the totals for those who attend regularly and do not attend regularly.
A) P(receives A's | attends regularly) =
B) P(receives A's | does not attend regularly) =
C) P(receives A's) =
D) P(attends regularly | receives A's) =
E) P(does not attend regularly | does not receive A's) =
In: Statistics and Probability