Questions
•• P11.1 Phone numbers and PIN codes can be easier to remember when you find words...

•• P11.1 Phone numbers and PIN codes can be easier to remember when you find words that
spell out the number on a standard phone keypad. For example, instead of remembering
the combination 2633, you can just think of CODE.
Write a recursive function that, given a number, yields all possible spellings (which
may or may not be real words).
•• P11.2 Continue Exercise P11.1, checking the words against the /usr/share/dict/words file on
your computer, or the words.txt file in the companion code for this book. For a given
number, return only actual words.
••• P11.3 With a longer number, you may need more than one word to remember it on a
phone pad. For example, 846-386-2633 is TIME TO CODE. Using your work from
Exercise P11.2, write a program that, given any number, lists all word sequences that
spell the number on a phone pad.
••• P11.4 Change the permutations function of Section 11.4 (which computed all permutations
at once) to a PermutationIterator (which computes them one at a time).
class PermutationIterator
{
public:
PermutationIterator(string s) { . . . }
string next_permutation() { . . . }
bool has_more_permutations() { . . . }
};
Here is how you would print out all permutations of the string "eat":
PermutationIterator iter("eat");
while (iter.has_more_permutations())
{
cout << iter.next_permutation() << endl;
}
Now we need a way to iterate through the permutations recursively. Consider the
string "eat". As before, we’ll generate all permutations that start with the letter 'e',

then those that start with 'a', and finally those that start with 't'. How do we generate
the permutations that start with 'e'? Make another PermutationIterator object
(called tail_iterator) that iterates through the permutations of the substring "at". In
the next_permutation function, simply ask tail_iterator what its next permutation is,
and then add the 'e' at the front. However, there is one special case. When the tail
iterator runs out of permutations, all permutations that start with the current letter
have been enumerated. Then
• Increment the current position.
• Compute the tail string that contains all letters except for the current one.
• Make a new permutation iterator for the tail string.
You are done when the current position has reached the end of the string.
••• P11.5 The following program generates all permutations of the numbers 0, 1, 2, ... , n – 1,
without using recursion.
#include <iostream>
#include <vector>
using namespace std;
void swap(int& x, int& y)
{
int temp = x;
x = y;
y = temp;
}
void reverse(vector<int>& a, int i, int j)
{
while (i < j)
{
swap(a[i], a[j]); i++; j--;
}
}
bool next_permutation(vector<int>& a)
{
for (int i = a.size() - 1; i > 0; i--)
{
if (a[i - 1] < a[i])
{
int j = a.size() - 1;
while (a[i - 1] > a[j]) { j--; }
swap(a[i - 1], a[j]);
reverse(a, i, a.size() - 1);
return true;
}
}
return false;
}
void print(const vector<int>& a)
{
for (int i = 0; i < a.size(); i++)
{
cout << a[i] << " ";
}
cout << endl;

}
int main()
{
const int n = 4;
vector<int> a(n);
for (int i = 0; i < a.size(); i++) { a[i] = i; }
print(a);
while (next_permutation(a)) { print(a); }
return 0;
}
The algorithm uses the fact that the set to be permuted consists of distinct numbers.
Thus, you cannot use the same algorithm to compute the permutations of the
characters in a string. You can, however, use this technique to get all permutations of
the character positions and then compute a string whose ith character
is s[a[i]]. Use
this approach to reimplement the generate_permutations function without recursion.
•• P11.6 Refine the is_palindrome function to work with arbitrary strings, by ignoring nonletter
characters and the distinction between upper- and lowercase letters. For
example, if the input string is
"Madam, I’m Adam!"
then you’d first strip off the last character because it isn’t a letter, and recursively
check whether the shorter string
"Madam, I’m Adam"
is a palindrome.

In: Computer Science

Question: Properly convert the solution to this problem from Java to C++ Problem Statement If you...

Question: Properly convert the solution to this problem from Java to C++

Problem Statement

If you want to write a message anonymously, one way to do it is to cut out letters from headlines in a newspaper and paste them onto a blank piece of paper to form the message you want to write. Given several headlines that you have cut out, determine how many messages from a list you can write using the letters from the headlines. You should only consider each message by itself and not in conjunction with the others, see example 2.

Write the function how_many which takes as parameters a vector<string> headlines containing the headlines which you have cut out as well as a vector<string> messages with the messages you may want to write, and returns an int which is the total number of messages you can write.

Constraints

  • All letters that you cut out can be used both as upper or lower case in a message.
  • Spaces should be ignored in elements in both headlines and messages.
  • headlines will contain between 1 and 50 elements, inclusive.
  • messages will contain between 1 and 50 elements, inclusive.
  • The length of each element in headlines will be between 1 and 50 characters, inclusive.
  • The length of each element in messages will be between 1 and 50 characters, inclusive.
  • Each element in headlines will only contain the letters 'A'-'Z', 'a'-'z' and space.
  • Each element in messages will only contain the letters 'A'-'Z', 'a'-'z' and space.

Examples

  1. headlines =
    
    {"Earthquake in San Francisco",
     "Burglary at musuem in Sweden",
     "Poverty"}
    
    messages =
    
    {"Give me my money back",
     "I am the best coder",
     "TOPCODER"}
    
    Returns: 2
    

    In the first message we have three 'm's, but there are only two 'm's among the headlines (both in the word "museum"), so this message can't be written.

    The second message can be written. Note that the first letter, 'I', only appears as lower case in the headlines, but that's allowed. The last message can also be written, so the method should return 2.

  2. headlines = 
    
            {"Programming is fun"}
    
    messages = 
    
            {"program","programmer","gaming","sing","NO FUN"}
    
    Returns: 4
    

    The messages "program", "gaming", "sing" and "NO FUN" can all be written but not "programmer" (no 'e's exist). The method should return 4.

  3. headlines = 
    
       {"abcdef","abcdef"}
    
    messages = 
    
       {"AaBbCc","aabbbcc","   ","FADE"}
    
    Returns: 3
    

    All messages except the second one can be written, because it contains three 'b's but there are only two 'b's available. Also note the message only containing spaces - such a message can of course always be written.

Given Function

#include <vector>
#include <string>

int how_many(vector<string> headlines, vector<string> messages) {
// fill in code here
}

Solution (Convert the Java code below to C++).

import java.util.*;

public class Anonymous {
      public int howMany(String[] headlines, String[] messages) {
          
    
          HashMap<Character, Integer> lettersAvailable = countLetters(headlines);

          int wordsWeCanMake = 0; 
          for(String message : messages){
                  String[] oneMessage = {message}; 
                  HashMap<Character, Integer> lettersNeeded = countLetters(oneMessage);
                  boolean canMakeMessage = true;
                  Iterator it = lettersNeeded.entrySet().iterator(); 
                  while (it.hasNext()){
                          Map.Entry pairs = (Map.Entry)it.next();
                          char key = (Character) pairs.getKey(); 
                          if(!(key==' ')){
                                  int numNeeded = (Integer) pairs.getValue();
                                  if(lettersAvailable.containsKey(key)){
                                          int numAvailable = lettersAvailable.get(key); 
                                          canMakeMessage = (numNeeded <= numAvailable) && canMakeMessage;
                                  }
                                  else{
                                          canMakeMessage = false ; 
                                          break;
                                  }
                          }
                          
                      it.remove();
                  }
                  if(canMakeMessage){
                          wordsWeCanMake += 1; 
                  }
          }
          return wordsWeCanMake; 
      }
      
      public HashMap<Character, Integer> countLetters(String[] words){
          HashMap<Character, Integer> counts = new HashMap<Character, Integer>();
          int currentCountOfLetter = 0;
          
          for(String word : words){  
                  for(int i=0; i<word.length(); i++){
                          char letter = Character.toLowerCase(word.charAt(i));
                          if (counts.containsKey(letter)){
                                  currentCountOfLetter = counts.get(letter);
                                  currentCountOfLetter +=1; 
                          }
                          else {
                                  currentCountOfLetter = 1;
                          }
                          counts.put(letter, currentCountOfLetter); 
                  }
          }
          
          return counts; 
      }
      }
}

In: Computer Science

Critical Thinking The market for young people's food products has increased considerably in recent years. As...

Critical Thinking

The market for young people's food products has increased considerably in recent years. As a result, children have become high-potential customers and are now the focus of intense and specialized marketing and advertising efforts.

Children and adolescents have become attractive consumers and influencers: they have an increasing influence on their family's purchases.Childrenrepresent an important target audience for marketers because they have their own purchasing power, influence their parents' purchasing decisions, and are the consumers of tomorrow. Advertisers have an interest in seducing them from an early age.Thus, to be sure to attract young people, companies opt for a combination of different approaches and channels such as television advertising, contests and games, toys, the use of popular characters, the use of various attractive colors, school marketing, Internet and branded products etc.

Food and beverages products that target children have increased and these productsare dominated by foods that are high in calories, sugars, salt, fat, low in nutrients and therefore not compatible with national dietary recommendations.

Mr. Fahmy has already a business in the food sector and wants to open a new subsidiary specializing in natural and organic products for children. The goal is to provide healthy, nutritious food and use healthier ingredients.

Questions

1. Help Mr. Fahmy define his overall goals, objectives and strategies for his new business in the context of his mission and purpose.

2. Briefly describe the choices that Mr. Fahmy can make for each of the 4 Ps of the marketing mix.

3. Identify the target market and describe how Mr. Fahmy's activities will respond better than the competition to the needs of the consumer. (List consumer expectations for the product)

4. Describe the type of promotional methods that you recommend to Mr. Fahmy for the promotion of his product line. (Identify techniques such as word of mouth, personal sales, direct marketing, sales promotion, etc., on television, radio, social media, and newspapers).

5. Why is it important for a media planner to consider how different types of media could work together on a media plan?

In: Operations Management

Two different machines, A and B, used for torsion tests of steel wire were tested on...

Two different machines, A and B, used for torsion tests of steel wire were tested on 12 pairs of different types of wire, with one member of each pair tested on each machine.

The results (break angle measurements) were as follows:

Machine A: 32, 35, 38, 28, 40, 42, 36, 29, 33, 37, 22, 42

Machine B: 30, 34, 39, 26, 37, 42, 35, 30, 30, 32, 20, 41

[a] Construct a side-by-side boxplot to display the two data sets and comment on interesting features.                                                                                                                                                                  [4 pt]

[b] Construct a QQ-plot (with a qqline) for each data set.                                                                 [3 pt]

How would you describe your Q-Q plot?

[c] Perform a Shapiro-Wilks normality test on each data set. What are the results regarding the data sets?                                                                                                                                                                        [3 pt]

[d] Based on your results [a] through [c], can you conduct a two-sample t-test for the data sets? Explain your response.                                                                                                             

Answer:           Yes                  No                   E Circle one                                                              [1 pt]

Explanation:                                                                                                                                       [3 pt]

[e] Is there evidence at the 5% significance level to suggest that machines A and B give different mean readings?

Write the null and alternative hypotheses test symbolically and verbally.                                        [8 pt]

Use R to get analysis results. State what the results tell you about the data.                                     [8 pt]

[f] Is there evidence at the 5% significance level to suggest that machine B gives a lower average reading than machine A?

Write the null and alternative hypotheses test symbolically and verbally.                                        [8 pt]

Use R to get analysis results. State what the results tell you about the data.                                     [8 pt]

[g] Your R codes or Excel commands for parts [a], [b], [c], [e], and [f] are required for credit.      [10 pt]

Copy and paste them here or paste them onto a blank MS Word document.

In: Statistics and Probability

Each group recorded the level of carbon monoxide measured (ppm) in a running car every 15 seconds for 2 minutes with a Graywolf indoor/outdoor air quality monitor

 

  1. For the data below create a table in excel and a graph to accompany. (the table and graph are two separate supplements so make sure each is labeled and formatted properly.) Hint: You are making the table in excel because you can make the graph straight from the data.

Each group recorded the level of carbon monoxide measured (ppm) in a running car every 15 seconds for 2 minutes with a Graywolf indoor/outdoor air quality monitor. They start recording at zero seconds.

Group 1, 1994 Ford Focus: 58, 50, 42, 36, 30, 25, 25, 24, 23

Group 2, 2008 Ford F150: 12, 15, 15, 16, 17, 16, 15, 14, 15

Group 3, 1988 Chevy Nova: 112, 80, 80, 70, 60, 55, 45, 40, 40

Group 4, 2014 Honda Accord: 12, 14, 16, 20, 30, 30, 35, 40, 48

Group 5, 2010 Hyundai Santa Fe: 50, 45, 43, 42, 30, 23, 13, 8, 7

Group 6, 2003 Subaru Forester: 66, 45, 40, 33, 32, 21, 20, 120, 17

  1. Create a table in Microsoft word for the following data.

Scientists tracked and observed a Black Bear (Ursus Americanus) named Stachi over the course of 6 years. Once a year they would document her weight and height, geolocation, fetal development, and body condition.

December 1999- 97 lbs., 55 in., (39.7576202, -74.1062466), No, Average

December 2000- 135 lbs., 55 in., (39.695866, -74.253511), Yes, Fat

December 2001- 102 lbs., 55 in., (39.5585, -74.3706), No, Average

December 2002- 99 lbs., 55 in., (39.7576202, -74.1062466), No, Average

December 2003- 122 lbs, 55 in., (39.695866, -74.253511) Yes, Fat

December 2004- 70 lbs., 54 in., (39.49026, -74.53915), No, Thin

In: Statistics and Probability

Abc Corporation was incorporated on December 1, 2019 and had following transactions during December 1 Dec...

Abc Corporation was incorporated on December 1, 2019 and had following transactions during December

1 Dec Issued Capital for 5000 cash

 3 Dec Paid 1200 cash for three months rent in advance

 4 Dec Purchased a used truck for 10,000 on credit

 4 Dec Purchased Supplies of 1000 on credit

 6 Dec Paid 1800 for a one-year truck insurance policy

 7 Dec Billed a customer 4500 for work completed to date

 8 Dec Collected 800 for work completed to date

 12 Dec Paid the following expense in cash

 Advertisement 350

 Interest 100

 Telephone 75

 truck operating 425

 Wages 2500 

15 Dec Collected 2000 of the amount billed on 7 dec

 18 Dec Billed Customer 6500 for work completed to date

 19 Dec Signed a 9000 contract for work to be performed in Jan 2017

 22 Dec Paid the following Expenses

 Advertisement 200

 Interest 150

 Truck Operating 375

 Wages 2500

 27 Dec Collected advance on work to be done in January

 28 Dec Received a bill for 100 for electricity used during the month

Additional Information The following information relates t0 31 Dec , 2016 One month of the prepaid insurance has expired The December portion of the rent paid is expired A physical count indicates that 350 of supplies is still on hand The amount collected as advance is unearned Three days of wages for Dec 29 30 31 are unpaid: Unpaid amount of 1500 will be included in first wages payment in Jan The truck has an estimated useful life of 4 years Income tax expenses are 500. The amount is to be paid next year.

Required:

Prepare trasaction summary,general journal, entries to ledger account, trial balance,adjusted trial balnce, financial statemment(income statement,owners equity,balance sheet), close temporary accounts and worksheet.

Intructions: should be handwritten or word file depend on you

In: Accounting

Variables typically included in a multivariate demand function (other than the price and quantity of the...

Variables typically included in a multivariate demand function (other than the price and quantity of the item the demand function represents) are consumer tastes and preferences, the number of buyers, spendable (disposable) income, prices of substitute goods, prices of complementary goods, advertising expenditures, weather, and expectations.  Recalling that the price of the item being considered is placed on the vertical axis, and the quantity on the horizontal axis, the other variables are termed demand shifters.  Please answer the following questions about the affect changes in other variables might have on the demand for the item.  These changes will either cause demand to increase (shift right) or decrease (shift left).  Use either word as applicable, for the short answer.

  1. Vehicle owners wishing to drive into central London must purchase passes to do so costing about $13.00 (as of 6-2011) per day. The policy is attempting to reduce traffic congestion and pollution.  It has been in effect for several years.  A long-term effect of the policy is to _______________ the demand for office space in Central London thus increasing building vacancies.

2.    The price of petrol in London (as of 6-2011) was about $12 - $13 per gallon.  As a result, the demand          for bicycles is _________________.

3.    Vehicle license plates in England increase sharply in price the older is the age of the vehicle.  As a result, the demand for new vehicles is _________________ and the demand for used vehicles is ______________.  This policy encourages the purchase of ever more efficient vehicles.

4.   Monthly rates for single-line household plain old telephone service (POTS) keeps increasing.  Cell phone rates increase too, but their service plans offer more options when the rate is increased.  Many therefore are _____________ their demand for plain old telephone service.

5.   I have my own Italian espresso machine.  Occasionally I opt for a commercial medium-sized Latte for $3.44 a drink.  My favorite coffee store has, however, raised the price to $3.99 per drink.  I am thus likely to ______________ my demand for their Lattes

In: Economics

Detailed Instructions: In a business setting, we are often asked to write a memo to communicate...

Detailed Instructions:
In a business setting, we are often asked to write a memo to communicate with internal and external professionals. To further advance your learning of memo communication, this written case requests that you prepare a memo to communicate within the company.

Background:

As the senior accountant at Technology on Demand (TOD), which manufactures mobile technology such as flip phones, smartphones, notebooks, and smartwatches, you are often asked to prepare various financial analysis necessary for decision making. Michelle Dodd, the controller, asked you to evaluate whether a piece of factory equipment should be replaced or kept.

The old piece of factory equipment was purchased four years ago for $875,000. Over the last four years, TOD has allocated depreciation based on the straight-line method. The expected salvage value is $25,000. The current book value of the factory equipment is $425,000. The operating expenses total approximately $45,000 a year. It is estimated that the residual value (market value) of the old machine is $350,000.      

The controller is contemplating whether to replace the piece of factory equipment. The replacement factory equipment would consist of a purchase price of $500,000, a useful life of eight years, salvage value of 30,000, and annual operating costs of $35,000.

In consideration of the background, prepare a memo in a Word document to submit to the controller. Your first paragraph would be an introduction paragraph of what the memo is about. Next, you will want to consider the equipment replacement decision. To add clarity to your discussion, you are to insert a table comparing the old equipment to the new equipment. In evaluating the “relevant” costs, what does your analysis show? Do you recommend that the equipment be replaced or kept ongoing for the next eight years? Why or why not?

Hint: See Equipment Replacement Decisions (LO 6-5) in chapter 6 located on page 268 and 269 of the hard copy text book. A piece of equipment with salvage value can still be serviceable after beyond its useful life. Be sure to focus on the “relevant costs.”

In: Finance

You are an assistant to the attorney for FUN company. To complete this assignment you must...

You are an assistant to the attorney for FUN company. To complete this assignment you must write a two-to-three page report discussing the legal issues and likely outcome of the case below:

SAD Co. vs. FUN Company: Several weeks ago, SAD Co. CEO met with FUN’s CEO for lunch to discuss potential business ventures between both companies. After a few shots of whiskey, SAD’s CEO tells FUN’s CEO that SAD is interested in purchasing a commercial building that FUN owns in a central area in West Palm Beach. SAD is interested in this building because of the specific location in which it is located. SAD believes that owning a building in that specific location will increase their business significantly. SAD’s CEO offers FUN’s CEO to purchase that specific building for $5 million. FUN’s CEO responds that FUN estimates that the building is worth $9 million and that they are willing to sell the building for that price give that they have no use for it. SAD’s CEO takes out a $1.00 bill gives it to FUN’s CEO and says “this is my payment so that you give me time to talk to my board and see if we are willing to pay $9 million.” FUN’s CEO laughs and puts the $1.00 bill in his pocket. Both CEO’s shake hands and say goodbye and leave. The next day SAD’s CEO calls an emergency meeting to discuss the $9 million purchase price and the board agrees to the purchase of the building for $9 million. Immediately after the meeting, SAD’s CEO calls FUN’s CEO on the phone and tells him that SAD agrees to purchase the building for $9 million. FUN’s CEO tells SAD’s CEO that FUN has decided not to sell the building because after their meeting yesterday they realized how much potential the building actually had. SAD is now demanding that FUN honor its word and sell them the building for$9 million.

In: Accounting

During the current year, Skylark Company had operating profit of $150,000. In addition, Skylark had a...

During the current year, Skylark Company had operating profit of $150,000. In addition, Skylark had a long-term capital loss of $10,000. Toby is the sole owner of Skylark Company. Please answer the following. Be sure to label each answer with the identifying number of the question. You can separate each answer with a comma. Type the word none is the amount is zero. Do not enter the number 0 or you will be marked wrong! Scenario 1: Skylark is a single-member LLC reporting on Schedule C, and Toby does not withdraw any funds from the company during the year. Enter None if the answer is 0. a. Toby will show how much ordinary income on his 1040 Schedule C? __________ b. Toby will deduct how much capital loss on his 1040 assuming he has no other capital gain and losses? ______ Scenario 2: Skylark is a regular (C) corporation, and Toby does not withdraw any funds from the company during the year. Enter None if the answer is 0. c. What is the total amount Toby will show on his 1040

the year from Skylark? ________ Scenario 3: Skylark is a regular (C) corporation, and Skylark makes a cash distribution of $100,000 to Toby during the year. Enter None if the answer is 0. d. Toby will report how much income on his 1040 for the year from Skylark?______ e. Skylark Corporation will report taxable income of how much for the year on their 1120? ______ Scenario 4: Skylark is a regular (C) corporation, and Skylark pays a salary of $100,000 to Toby during the year. Show the income reported by Toby on his individual income tax return from Skylark Company. Enter None if the answer is 0. f. Toby will report how much income on his 1040 for the year from Skylark?______ g. Skylark Corporation will report taxable income of how much for the year on their 1120? ______

In: Accounting