Java Language
Add a recursive method to the program shown in the previous section that allows remove the last node from the stack.
Code:
class Stack {
protected Node top;
Stack() {
top = null; }
boolean isEmpty() {
return( top == null); }
void push(int v) {
Node tempPointer;
tempPointer = new Node(v);
tempPointer.nextNode = top;
top = tempPointer; }
int pop() {
int tempValue;
tempValue = top.value;
top = top.nextNode;
return tempValue; }
void printStack() {
Node aPointer = top;
String tempString = "";
while (aPointer != null) {
tempString = tempString + aPointer.value + "\n";
aPointer = aPointer.nextNode; }
System.out.println(tempString); }
boolean hasValue(int v) {
if (top.value == v) {
return true; }
else {
return hasValueSubList(top,v);
}
}
boolean hasValueSubList(Node ptr, int v) {
if (ptr.nextNode == null) {
return false; }
else if (ptr.nextNode.value == v) {
return true; }
else {
return hasValueSubList(ptr.nextNode,v);
}
}
}
class Node {
int value;
Node nextNode;
Node(int v, Node n) {
value = v;
nextNode = n;
}
Node (int v) {
this(v,null);
}
}
public class StackWithLinkedList2{
public static void main(String[] args){
int popValue;
Stack myStack = new Stack();
myStack.push(5);
myStack.push(7);
myStack.push(9);
System.out.println(myStack.hasValue(11));
}
}
System.out.println(myStack.hasValue(11)); } }
System.out.println(myStack.hasValue(11)); } } System.out.println(myStack.hasValue(11)); } }
In: Computer Science
| 6-year Graduation Rate | |||
| Status | All students | athletes | |
| Duke | Private | 95% | 87% |
| UNC-CH | Public | 86% | 74% |
| NCSU | Public | 71% | 51% |
| Wake | Private | 88% | 80% |
| ECU | Public | 54% | 58% |
| UNC-C | Public | 51% | 59% |
| BC | Private | 91% | 90% |
| Clemson | Public | 79% | 66% |
| FSU | Public | 70% | 53% |
| Ga Tech | Public | 77% | 56% |
| U-MD | Public | 82% | 66% |
| Miami | Private | 77% | 70% |
| UVA | Public | 93% | 73% |
| Va Tech | Public | 78% | 72% |
| UC-Davis (D-II) | Public | 81% | 81% |
| Florida | Public | 82% | 61% |
| UGA | Public | 79% | 59% |
| Illinois | Public | 82% | 70% |
| Iowa St | Public | 67% | 79% |
| Michigan St | Public | 75% | 66% |
| Minnesota | Public | 66% | 71% |
| Ohio State | Public | 73% | 67% |
| Penn State | Public | 85% | 76% |
| Public | 72% | 66% | |
| Texas A&M | Public | 78% | 61% |
| Wisconsin | Public | 81% | 59% |
The graduation rate of college students is a subject of considerable interest and is a frequent topic in the news. College/university administrators use the graduation rate as a barometer of student success at their respective institution. State legislators are interested in the graduation rate since most states subsidize the cost of educating each in-state student at public universities and colleges.
Graduation rates are also used to evaluate university athletic programs. Athletic directors do not relish the negative publicity that results when the graduation rate of athletes is significantly lower than that of the general student body.
This Excel file graduation rates shows recent 6-year graduation rates for athletes and the general student body at 26 universities. The institutions included are all ACC schools, NCSU peer-designated institutions, and two of the larger schools in the UNC system - ECU and UNC-Charlotte.
Question. Use the data above to find the quartiles and the median of the general student body graduation rates and the athlete graduation rates (use the method discussed in class for calculating quartiles; see the Tukey method on p.58 of the ebook/text or p. 23 in Lecture Unit 2 of the coursepack).
____% Q1, first quartile for general student body
graduation rate
_____ % Q1, first quartile for athlete graduation
rate
_____ % median, general student body graduation rate
_______% median, athlete graduation rate
_____% Q3, third quartile for general student body
graduation rate
_____% Q3, third quartile for athlete graduation
rate
In: Math
| Rx: | |
| Castor oil | 10% (v/v) |
| Tween 80 and Span 20 | 2% (w/v) |
| Simple syrup | qs 50 mL |
How many gram(s) of Span 20 are needed to prepare for the prescription, given that the required HLB for the emulsion is 10, Span 20 has an HLB of 8.6, and Tween 80 has an HLB of 15?
In: Nursing
In java.
Write a method static <K, V> void addToMultiMap(Map<K, Set<V>> map, K key, V value). addToMultiMap must add the value, if present, to the set associated with the given key, creating the set if necessary. You may assume all keys already in the map are associated with non-null values.
For full credit, your method must include generic types, and must not contain unnecessary method calls or loops, even if they do not otherwise impact correctness. You may assume Map, Set, HashMap, and HashSet are correctly imported from java.util. You may not import other classes.
In: Computer Science
in C++.
Implement a structure to handle a college course information. You will also use functions to manipulate the structure. Follow the instructions step by step to complete the homework successfully.
(1) Create a structure course. The structure should include the following attributes:
Important! The names of the structure and each of its field must match exactly for the program to work and be graded correctly.
Before moving on with the exercise, it is recommended that you self-test your structure in the main function (create a structure, assign values and print them…). Just make sure to remove these changes from the main before you continue.
(2) function getCourseFromFile(). This function takes as argument the name of a file where course information is stored, reads the file, and returns a structure with that information.
The format of the file is the following:
<Course name> <Course code> <Course class size> <Student1> <Student2> <Student3> ...
In the function, open a file stream using the file name passed as argument. If the file is not opened successfully, print
Error! File not found.
Else, read the information from the file into a local structure variable (the variable to be returned). You can assume that the number of students in the file will not exceed the size of the array.
Note that the number of students enrolled is not know and has to be determined while reading the list of names in the file.
This function is tested using unit testing.
(3) function checkCourseSize(). This function takes as argument a course structure and returns true if the number of students enrolled is less or equal the class size, and false otherwise.
This function is tested using unit testing.
(4) function printRoster(). This function takes as argument a course structure and prints all the students to standard output, each one on a new line.
(5) function saveCourseSummary(). This function takes two arguments: a string with the desired output file name, and a course structure. Then saves in the output file the following course summary:
Course title: <title> Course code: <code> Class size: <size> Students enrolled: <enrolled>
Additionally, it uses the function checkCourseSize and if the function returns false (too many students enrolled), it adds to the file the following message:
Enrollment exceeds class size. Drop students or find bigger classroom.
In: Computer Science
Researcher conducts a study to decide whether support groups
improve academic performance for at-risk high school students. Ten
such students are randomly selected to take part in the support
group for a semester, while the other 10 at-risk students serve as
a control group. At the end of the semester, the improvement in GPA
versus the previous semester is recorded for each student.
Support Group: 0.5, 0.8, 0.7, 0.7, -0.1, 0.2, 0.4, 0.4, 0.5,
0.4
Control Group: -0.3, 0.0, -0.1, 0.2, -0.1, -0.2, -0.2, 0.0, -0.1,
0.1
At the 10% level, use R to compare the two groups using a permutation test (with 100,000 randomly generated permutations). You need to write your hypotheses, the test statistic, the pvalue, and the decision/conclusion in the context of the problem.
R code for reference:
SupportGroup <- c(0.5, 0.8, 0.7, 0.7, -0.1, 0.2, 0.4, 0.4,
0.5, 0.4)
ControlGroup <- c(-0.3, 0.0, -0.1, 0.2, -0.1, -0.2, -0.2, 0.0,
-0.1, 0.1)
mean(SupportGroup);sd(SupportGroup)
mean(ControlGroup);sd(ControlGroup)
#permutation test on difference of means
choose(20,10)#number of possible permutations
new.dat <- c(SupportGroup,ControlGroup)
obs.mean.diff <- mean(SupportGroup) - mean(ControlGroup)
nsim <- 100000
sim.mean.diff <- rep(NA,length=nsim)
for (i in 1:nsim){
grps <- sample(c(rep(1,10),rep(2,10)),replace=FALSE)
sim.mean.diff[i] <- mean(new.dat[grps==1]) -
mean(new.dat[grps==2])
}
hist(sim.mean.diff);abline(v=obs.mean.diff,col="red",lty=2)
length(sim.mean.diff[sim.mean.diff<=obs.mean.diff])/nsim
#estimated p-value
In: Math
Prove the following formulas, where u, v, z are complex numbers and z = x +iy.
a. sin(u+v) = sin u cos v + cos u sin v.
b. cos(u+v) + cos u cos v - sin u sin v.
c. sin^2 z + cos^2 z = 1.
d. cos(iy) = cosh y, sin (iy) = i sinh y.
e. cos z = cos x cosh y - i sin x sinh y.
f. sin z = sin x cosh y + i cos x sinh y.
In: Advanced Math
Solve the following dissolution exercises:
A. 3 aqueous solutions are mixed: 50 mL of 10% w/v HCl, 35 mL of
3.2% w/v NaCl and 65 mL of 13% w/v KCl, which is the final
concentration of the solution in %p/v with respect to H +, Na +, K
+, Cl-
B. What volumes of 8M, 5M and 3M HCl should be mixed to prepare 1 L of 6M HCl
C.
It is necessary to prepare 35 mL of 15% w/v H2O2 solution from a 5% w/v H2O2 solution and another 10% w/v solution. What volume should be used for each solution?
In: Chemistry
If V (dimension k-1) is a subspace of W (dimension K), and V has an orthonormal basis {v1,v2.....vk-1}. Work out a orthonormal basis of W in terms of that of V and the orthogonal complement of V in W.
Provide detailed reasoning.
In: Advanced Math
Given the balanced equation: 3Ni(s) + 2Au3+(aq) :⟶2Au(s) + 3Ni2+(aq), E^o_{cell}\:E c e l l o= 1.76 V, what is the cell potential for this reaction when [Au3+] = 0.95 M and [Ni2+] = 0.016 M at 298 K? Group of answer choices
1.78 V
1.71 V
1.81 V
1.92 V
In: Chemistry