Done in C++ please. And use #include iostream, string, and fstream. do not use #include algorithm.
Question 1 In this question, you will read words from a file and place them into an array of type string.
1- Make a data text file “words.txt” – that contains one word on each line. Use at least 20 words.
2- Now write a program that reads the words in the file into an array of strings (a repeated word should not be inserted into the array – your program should not allow that and you should make sure your data file has duplicate words to test this functionality). Make your array size enough to hold 1000 words. To read the words into the array, you should make a function that takes a string array, a data size integer (dsize) by reference and an ifstream – please look at the example we did in class.
3- Declare your array and file streams in main and call the function that reads the data into the array.
4- Write a printArray function that takes a string array, the dsize and an ostream object so that you could print to the console or to an output file.
5- Print your array from main by calling the printArray function – once to the console and once to a file “wordsoutput.txt”.
6- Use the selectionSort Algorithm that we covered in class to sort the array.
7- Repeat #5 and make sure the array is sorted.
8- Find the maximum string and the minimum string in the array (remember arrays are compared based on the ASCII value).
9- Write a function that takes a string and converts every character of it to uppercase. Now call that function from a function that you pass the array and dsize to, to uppercase all words in the array (convert all words in the array to uppercase letter) and call that from main passing your array to that function. Print the array.
In: Computer Science
A thin-walled, hollow spherical shell of mass m and radius r starts from rest and rolls without slipping down the track shown in the figure (Figure 1) . Points A and Bare on a circular part of the track having radius R. The diameter of the shell is very small compared to h0 and R, and rolling friction is negligible. a) What is the minimum height h0 for which this shell will make a complete loop-the-loop on the circular part of the track? b) How hard does the track push on the shell at point B, which is at the same level as the center of the circle? c) Suppose that the track had no friction and the shell was released from the same height h0 you found in part (a). Would it make a complete loop-the-loop? d) In part (c), how hard does the track push on the shell at point A, the top of the circle? e) How hard did the track push on the shell at point A in part (a)?
In: Physics
1. How does the electrical current pathway differ between monopolar and bipolar?
2. Why might a patient’s jewelry be hazardous in the OR?
3. What are the safety precautions to be considered with the placement of the patient return electrode?
4. What are the three properties of laser light which are different than normal light?
5. How is distention achieved in minimally invasive procedures and why is it necessary?
6. What types of trocars are used for laparoscopy and what are their advantages?
7. Why are angled rigid endoscope used and in which types of procedures would they be preferred?
8. Which types of human motions or movements are surgical robots able to replicate?
9. What are the reasons for creating hybrid rooms within the operating room suite?
In: Nursing
Was inadequate regulation the reason for the demise of Northern Rock? Support your answer
with evidence.
In: Economics
In an experiment performed at the bottom of a very deep vertical mine shaft, a ball is tossed vertically in the air with a known initial velocity of 10.0 m/s, and the maximum height the ball reaches (measured from its launch point) is determined to be 5.101 m. Knowing the radius of the Earth, RE = 6370 km, and the gravitational acceleration at the surface of the Earth, g(0) = 9.81 m/s2, calculate the depth of the shaft.
In: Physics
Kindly type the answer but don't copy and paste - 250 words
Compare and contrast the Linear Classifier and Decision Tree Classifier
In: Computer Science
Let x be the average number of employees in a group health insurance plan, and let y be the average administrative cost as a percentage of claims.
x 3 7 15 39 73
y 40 35 30 25 20
(a) Make a scatter diagram of the data and visualize the line you think best fits the data.
(b) Would you say the correlation is low, moderate, or strong? positive or negative?pLEASE SELECT CORRECT ANSWER
moderate and positive
low and negative
moderate and negative
low and positive
strong and positive
strong and negative
(c) Use a calculator to verify that Σx = 137, Σx2 = 7133, Σy = 150, Σy2 = 4750, and Σxy = 3250. Compute r. (Round your answer to three decimal places.) r =
As x increases, does the value of r imply that y should tend to increase or decrease? Explain. SELECT CORRECT ANSWER
Given our value of r, y should tend to decrease as x increases.
Given our value of r, y should tend to increase as x increases.
Given our value of r, y should tend to remain constant as x increases.
Given our value of r, we cannot draw any conclusions for the behavior of y as x increases.
In: Math
0. Introduction.
This laboratory assignment involves designing a perfect hash function for a small set of strings. It demonstrates that a perfect hash function need not be hard to design, or hard to understand.
1. Theory.
We’ll start by reviewing some terminology from the lectures. A
hash function is a function that takes a key as
its argument, and returns an index into an array. The array is
called a hash table. The object that appears at the index
in that array is the key’s value.The key’s value is
somehow associated with the key.
A hash function may return the same
index for two different keys. This is called a collision.
Collisions are undesirable if we want distinct values to be
associated with distinct keys. A hash function that has no
collisions for a set of keys is said to be perfectfor that
set. Note that a hash function may be perfect for some sets of
keys, but not perfect for others.
Most modern programming languages
use a small set of reserved names as operators,
punctuation, and syntactic markers. (They’re also called
reserved words or keywords.) For example, Java
currently uses reserved names like if, private, while, etc.
A compiler for a programming
language must be able to test if a name in a program is reserved.
Programs may be hundreds or thousands of pages long, and may
contain thousands or even millions of names. As a result, the test
must be done efficiently. It might be implemented using a hash
table and a perfect hash function.
Here’s how the test may work.
Suppose that the hash table T is an array of strings. Each
time the compiler reads a name N, it calls a perfect hash
function h to compute an index h(N). If
h(N) is a legal index for T, and
T[h(N)] = N, then the name is
reserved, otherwise it is not. Unused elements of T might
be empty strings "". If we measure the efficiency of a test by the
number of string comparisons it performs, then the test requires
only O(1) comparisons. Of course this works only if
h is perfect for the set of reserved names.
Now suppose there is a very simple
programming language that uses the following set of twelve reserved
names.
|
and |
else |
or |
|
begin |
end |
return |
|
define |
if |
then |
|
do |
not |
while |
We might define a perfect hash function for the reserved names
in the following way. We get one or more characters from each name.
Then we convert each character to an integer. This is easy, because
characters are already represented as small nonnegative integers.
For example, in the ASCII and Unicode character sets, the
characters 'a' through 'z' are represented as the integers 97
through 122, without gaps. Finally, we do some arithmetic on the
integers to obtain an index into the hash table. We choose the
characters, and the arithmetic operations, so that no two reserved
names result in the same index.
For example, if we define the hash
function h so that it adds the first and second characters
of each name, we get the following indexes.
|
h("and") |
= |
207 |
|
h("begin") |
= |
199 |
|
h("define") |
= |
201 |
|
h("do") |
= |
211 |
|
h("else") |
= |
209 |
|
h("end") |
= |
211 |
|
h("if") |
= |
207 |
|
h("not") |
= |
221 |
|
h("or") |
= |
225 |
|
h("return") |
= |
215 |
|
h("then") |
= |
220 |
|
h("while") |
= |
223 |
This definition for h does not result in a perfect hash function, because it has collisions. For example, the strings "and" and "if" result in the index 207. Similarly, the strings "do" and "end" result in the index 211. We either didn’t choose the right characters from each string, or the right operations to perform on those characters, or both. Unfortunately, there is no good theory about how to define h. The best we can do is try various definitions, by trial and error, until we find one that is perfect.
2. Implementation.
Design a perfect hash function for the reserved names shown in the previous section. To do that, write a small test class, something like this, and run it with various definitions for the function hash. It calls hash for each reserved name, and writes indexes to standard output.
class Test
{
private static final String [] reserved
=
{ "and",
"begin",
"define",
"do",
"else",
"end",
"if",
"not",
"or",
"return",
"then",
"while" };
private static int hash(String name)
{
// Your code goes
here.
}
public static void main(String []
args)
{
for (int index = 0; index <
reserved.length ; index += 1)
{
System.out.print("h(\"" +
reserved[index] + "\") = ");
System.out.print(hash(reserved[index]));
System.out.println();
}
}
}
When defining hash, you might try adding characters at specific
indexes from each name. You might try linear combinations of the
characters: that is, multiplying the characters by small constants,
then adding or subtracting the results. You might try the operator
%. You might also try a mixture of these. Whatever you try, reject
any definition of hash that is not perfect: one that returns the
same index for two different names.
Your method hash must work in
constant time, without loops or recursions. It must not use if’s or
switch’es. It must not call the Java method hashCode, because that
uses a loop, and so does not work in O(1) time. It must
not return negative integers, because they can’t be array
indexes.
The character at index k in
name is obtained by name.charAt(k). Characters in Java
Strings are indexed starting from 0, and ending with the length of
the string minus 1. For example, the first character from name is
returned by name.charAt(0), the second character by name.charAt(1),
and the last character by name.charAt(name.length() - 1).
Don’t worry if there are gaps
between the indexes: your hash function need not be
minimal. Also, try to keep the returned indexes small:
they shouldn’t exceed 2000. For example, I know a perfect hash
function for the reserved words in this assignment, whose indexes
range from 1177 to 1413. I found it after about ten minutes of
trial-and-error search.
In: Computer Science
What are the various ways you can analyze financial statements? Hint: Vertical and common-sized are the same thing. Which method do you believe is used most often internally? Why? Which method do you believe is used most often by external stakeholders? Why? Of the different general types of ratios, liquidity, solvency, profitability, etc., which do you think are the most useful by the various stakeholders? Why?
In: Accounting
In: Math
In: Nursing
In: Physics
Please write in full sentences and atleast 1-2 paragraphs for each please.
-Correctly describe Groupthink in detail
-What questions do you now have after considering the event in light of psychological theory of groupthink
-What type of experiment(s) might help address groupthing further? Like how can we better our understanding of this? What experiments can we design to better understand it or explore more?
IMPORTANT If you can please find examples in greys anatomy in Season 2 episode 26 when they cut the LVAD wire.
Give an example of each of these from that scene please
•Insulated groups
•Don’t consider relevant info
•Normative pressure toward consensus
•Self-censorship
•Commitment to decisions
•Strong, opinionated leaders
In: Psychology
Simon Company’s year-end balance sheets follow.
| At December 31 | Current Yr | 1 Yr Ago | 2 Yrs Ago | ||||||
| Assets | |||||||||
| Cash | $ | 31,200 | $ | 34,800 | $ | 37,400 | |||
| Accounts receivable, net | 89,400 | 62,100 | 57,500 | ||||||
| Merchandise inventory | 50,220 | 82,300 | 50,000 | ||||||
| Prepaid expenses | 10,260 | 9,166 | 3,444 | ||||||
| Plant assets, net |
358,920 |
261,634 | 161,656 | ||||||
| Total assets | $ | 540,000 | $ | 450,000 | $ | 310,000 | |||
| Liabilities and Equity | |||||||||
| Accounts payable | $ | 134,460 | $ | 75,289 | $ | 39,692 | |||
| Long-term notes payable secured by mortgages on plant assets |
101,520 | 104,535 | 67,140 | ||||||
| Common stock, $10 par value | 162,500 | 162,500 | 162,500 | ||||||
| Retained earnings | 141,520 | 107,676 | 40,668 | ||||||
| Total liabilities and equity | $ | 540,000 | $ | 450,000 | $ | 310,000 | |||
The company’s income statements for the Current Year and 1 Year
Ago, follow.
| For Year Ended December 31 | Current Yr | 1 Yr Ago | ||||||||||
| Sales | $ | 702,000 | $ | 535,500 | ||||||||
| Cost of goods sold | $ | 428,220 | $ | 348,075 | ||||||||
| Other operating expenses | 217,620 | 135,482 | ||||||||||
| Interest expense | 11,934 | 12,317 | ||||||||||
| Income tax expense | 9,126 | 8,033 | ||||||||||
| Total costs and expenses | 666,900 | 503,907 | ||||||||||
| Net income | $ | 35,100 | $ | 31,593 | ||||||||
| Earnings per share | $ | 2.16 | $ | 1.94 | ||||||||
Additional information about the company follows.
| Common stock market price, December 31, Current Year | $ | 32.00 |
| Common stock market price, December 31, 1 Year Ago | 30.00 | |
| Annual cash dividends per share in Current Year | 0.32 | |
| Annual cash dividends per share 1 Year Ago | 0.16 | |
For both the Current Year and 1 Year Ago, compute the following
ratios:
1. Return on common stockholders' equity.
2. Price-earnings ratio on December 31.
2a. Assuming Simon's competitor has a
price-earnings ratio of 8, which company has higher market
expectations for future growth?
3. Dividend yield.
In: Accounting
Nguyen, Tran and Le are partners sharing profits and losses equally and with capital balances of $225, $675 and $450 respectively. Before Tran leaves the partnership the assets are revalued. An independent valuer assesses the equipment to be worth $12 less than the carrying amount (book value), and property $147 more than the carrying amount.
a) Prepare the journal entries to record the revaluation of property and equipment.
b) Prepare the journal entries to record the revaluation of property and equipment if the partnership agreement specifies profits and losses are allocated on the basis of the capital balances.
c) Prepare the journal entries to record the retirement of Tran (after revaluation and profits and losses are allocated on the basis of capital balances as in (b) above) if she is allowed to take $842.50 in cash (record to the nearest cent)
In: Accounting