There are wide applications of the searching algorithm, where given a list of objects, to find whether the search target is in the list.
The intuitive solution is that we walk through the list until the search target is found or the end of the list is reached. The solution is called Linear Search.
For general purpose, let us use ListADT and define a static generic linear search method as follows:
public static <T extends Comparable<T>> int search(ListADT<T> array, T targetValue) throws EmptyCollectionException;
Please implement the linear search method, which walks through the given list and search for the targetValue until the targetValue is found or the end of the list is reached. If the targetValue is found, the method returns the index of the targetValue in the list or else it returns -1.
public static <T extends Comparable<T>> int search(ListADT<T> array, T targetValue) throws EmptyCollectionException {
}
In the hands-out or your sketchbook, please write down your code and take a snapshot and submit it.
Additionally, discuss and answer the following question:
what are the worst and average case running times for serial search?
In: Computer Science
A child slides down a hill on a toboggan with an acceleration of 1.5 m/s2.
Part A If she starts at rest, how far has she traveled in 1.0 s? Express your answer using two significant figures. dd = nothing m
Part B If she starts at rest, how far has she traveled in 2.0 s? Express your answer using two significant figures. dd = nothing m
Part C If she starts at rest, how far has she traveled in 3.0 s? Express your answer using two significant figures. dd = nothing m
In: Physics
For the reaction 2 A(aq) <---> B(aq) + C(aq), the standard Gibbs free enthalpy change is 1.69 kJ at 25oC. The initial concentration of A(aq) is 0.549 M, the initial concentration of B(aq) is 0.327 M, and the initial concentration of C(aq) is 0.234 M. What would be the concentration of A(aq) (in mol/L) once we attain equilibrium (we are still at 25oC)?
In: Chemistry
If 20.00 mol of helium gas is at 17.0 ∘C and a gauge pressure of 0.320 atm .
Calculate the temperature in celcius if the gas is compressed to precisely half the volume at a gauge pressure of 1.00 atm. Original volume is 0.3608m3
In: Chemistry
One in four adults is currently on a diet. You randomly select ten adults and ask them if they are currently on a diet. Find the probability that the number who say they are currently on a diet is (a) exactly three, (b) at least three, (c) more then three, (d) at most four, and (e) less than six.
In: Math
Customer A B C D E F
Contracted amount (tons) 1 2 6 2 3 4
Rockbottom has five trucks that may be used to make these deliveries. With the use of dividers, a truck can deliver to multiple customers, as long as it does not exceed the truck’s capacity. However, a customer’s order cannot be broken up and delivered by multiple trucks. The available trucks and their capacities are:
Truck # 1 2 3 4 5
Capacity (tons) 4 8 4 8 6
The costs, in $000s, for each truck to deliver the required load to each customer are:
Customer
Truck A B C D E F
1 17 19 21 20 20 21
2 15 18 20 18 19 23
3 18 19 22 22 21 22
4 15 16 19 18 18 20
5 16 15 20 22 19 20
Develop a linear program to determine the delivery plan that will allow Rockbottom to minimize the cost of fulfilling their contracts.
In: Operations Management
Write a C++ program to check whether a number is prime or not. A prime number is a positive integer that has exactly two positive integer factors, 1 and itself. Eg: 2, 3, 5, 7, 11, 13, 17, ...
Sample Output:
Input a number to check prime or not: 13 The entered number is a
prime number.
Input a number to check prime or not: 28 The entered number is not a prime number.
Enhance the program to list all factors if the number is not
prime Input a number to check prime or not: 28
The entered number is not a prime number.
Factors: 1, 2, 4, 7, 14, and 28
In: Computer Science
A charge of -0.4 µC is located at the origin; a charge of 0.53 µC is located at x = 0.2 m, y = 0; a third charge Q is located at x = 0.32 m, y = 0. The force on the 0.53 µC charge is 4.3 N, directed in the positive x direction.
1. Determine the charge
2. With this configuration of three charges, where, along the x direction, is the electric field zero? xf=
3. x2=
In: Physics
provide an example(s) where advertising has positive benefits for consumers. Provide examples where advertising has negative effects. The Government has regulated certain advertising such as cigarettes and marketing to children. Should all advertising be regulated?
In: Economics
Calculate the height of a column of carbon tetrachloride, CCl4(l), with a density of 1.59 g/mL that exerts the same pressure as a 15.2 cm column of Mercury, Hg(l), that has a density of 13.6 g/ml. Express your answer in meters. Please only enter the numerical value of your answer.
In: Chemistry
Packaging Solutions Corporation manufactures and sells a wide variety of packaging products. Performance reports are prepared monthly for each department. The planning budget and flexible budget for the Production Department are based on the following formulas, where q is the number of labor-hours worked in a month:
| Cost Formulas | |
| Direct labor | $16.50q |
| Indirect labor | $4,500 + $1.40q |
| Utilities | $5,100 + $0.70q |
| Supplies | $1,400 + $0.30q |
| Equipment depreciation | $18,400 + $2.90q |
| Factory rent | $8,400 |
| Property taxes | $2,600 |
| Factory administration | $13,800 + $0.60q |
The Production Department planned to work 4,400 labor-hours in March; however, it actually worked 4,200 labor-hours during the month. Its actual costs incurred in March are listed below:
| Actual Cost Incurred in March | |||
| Direct labor | $ | 70,920 | |
| Indirect labor | $ | 9,840 | |
| Utilities | $ | 8,570 | |
| Supplies | $ | 2,930 | |
| Equipment depreciation | $ | 30,580 | |
| Factory rent | $ | 8,800 | |
| Property taxes | $ | 2,600 | |
| Factory administration | $ | 15,670 | |
Required:
1. Prepare the Production Department’s planning budget for the month.
2. Prepare the Production Department’s flexible budget for the month.
3. Calculate the spending variances for all expense items.
In: Accounting
C++ AVL tree
My AVL tree function
void inorder(AVLNode* t)
{
if (t == NULL)
return;
inorder(t->left);
cout << t->data.cancer_rate << " ";
inorder(t->right);
}
void inorder()
{
inorder(root);
}
Will Print my cancer city rate Inorder
example)...you can use any input as long it is a float
3.1
5.8
19.8
22.2
33.3
44.4
[Qustion]
How do I make a function that only prints the last one of my AVLTree ,in this case a function that only prints 44.4
And how do I make a function that only prints the first one of my AVLTree ,in this case a function that only prints 3.1
I think this can be accomplished by editing the inorder function
In: Computer Science
Compute the payback period, Internal Rate of Return and Net. Present Value. Assume a Discount Rate of 4%, Ivt. in Project is $1,500,000 Year Return ($) 1 300k 2 500k 3 400k 4 300k 5 200k 6 100k
In: Finance
A sample of a concentrated fluorescent reagent was serially diluted with three steps using a variable volume 100 to 500 μL micropipetor and 10.00 mL Class A volumetric flasks. The concentrated reagent had a fluorescent signal of 653.4 and the diluted sample produced 0.057 fluorescence units. Unfortunately the steps followed for the dilution were lost. What were those steps?
In: Chemistry
Explain why it is difficult to make an X-ray laser.
In: Physics