Questions
Write a recursive function to check if a string whose each character is stored in a...

Write a recursive function to check if a string whose each character is stored in a separate node in a doubly linked list, is a palindrome. Use the code available from DoublyLinkedList.hpp on our Github.

//
// Doubly-linked list with 2 dummy nodes
//
#pragma once
#include <stdexcept>
template<typename T>
struct Node {
T data;
Node<T>* next;
Node<T>* prev;
Node() = delete; // Intentionally no default constructor
Node( const T & element ) : data( element ), next( nullptr ), prev( nullptr ) {}
};
template<typename T>
class DoublyLinkedList {
private:
Node<T>* head;
Node<T>* tail;
public:
// Constructors
DoublyLinkedList();
DoublyLinkedList(const DoublyLinkedList&);
DoublyLinkedList& operator=(const DoublyLinkedList&); // assignment operator
~DoublyLinkedList(); // destructor
// Getters / Setters
bool empty();
int size() = delete; // INTENTIONALLY NOT IMPLEMENTED !!
void append( const T& );
void prepend( const T& );
void insertAfter( Node<T>*, const T& );
void remove( Node<T>* );
void pop_front(); // remove element at front of list
void pop_back(); // remove element at back of list
T& front(); // return list's front element
T& back(); // return list's back element
void clear();
};
template<typename T>
DoublyLinkedList<T>::DoublyLinkedList() {
head = new Node<T>( T() ); // create dummy nodes
tail = new Node<T>( T() );
head->next = tail; // have them point to each other
tail->prev = head;
}
template<typename T>
bool DoublyLinkedList<T>::empty() {
return head->next == tail;
}
template<typename T>
void DoublyLinkedList<T>::append( const T& newData ) {
Node<T> * newNode = new Node<T>( newData ); // create new node
newNode->prev = tail->prev;
newNode->next = tail;
tail->prev->next = newNode;
tail->prev = newNode;
}
template<typename T>
void DoublyLinkedList<T>::prepend( const T& newData ) {
Node<T> * newNode = new Node<T>( newData ); // create new node
Node<T> * firstNode = head->next;
newNode->next = head->next;
newNode->prev = head;
head->next = newNode;
firstNode->prev = newNode;
}
template<typename T>
void DoublyLinkedList<T>::insertAfter(Node<T>* curNode, const T& newData) {
if (curNode == tail) {
// Can't insert after dummy tail
return;
}
// Construct new node
Node<T>* newNode = new Node<T>( newData );
Node<T>* sucNode = curNode->next;
newNode->next = sucNode;
newNode->prev = curNode;
curNode->next = newNode;
sucNode->prev = newNode;
}
template<typename T>
void DoublyLinkedList<T>::remove(Node<T>* curNode) {
if( empty() ) throw std::length_error( "empty list" );
if (curNode == head || curNode == tail) {
// Dummy nodes cannot be removed
return;
}
Node<T>* sucNode = curNode->next;
Node<T>* predNode = curNode->prev;
// Successor node is never null
sucNode->prev = predNode;
// Predecessor node is never null
predNode->next = sucNode;
}
template <typename T>
void DoublyLinkedList<T>::pop_front() {
remove(head->next);
}
template <typename T>
void DoublyLinkedList<T>::pop_back() {
remove(tail->prev);
}
template <typename T>
T& DoublyLinkedList<T>::front() {
if( empty() ) throw std::length_error( "empty list" );
return head->next->data;
}
template <typename T>
T& DoublyLinkedList<T>::back() {
if( empty() ) throw std::length_error( "empty list" );
return tail->prev->data;
}
template<typename T>
void DoublyLinkedList<T>::clear() {
while( !empty() )
pop_front();
}
template<typename T>
DoublyLinkedList<T>::~DoublyLinkedList() {
clear();
delete head; // remove the dummy nodes
delete tail;
}
template <typename T>
DoublyLinkedList<T>::DoublyLinkedList( const DoublyLinkedList<T> & original ) : DoublyLinkedList() {
// Walk the original list adding copies of the elements to this list maintaining order
for( Node<T> * position = original.head->next; position != original.tail; position = position->next ) {
append( position->data );
}
}
template <typename T>
DoublyLinkedList<T> & DoublyLinkedList<T>::operator=( const DoublyLinkedList<T> & rhs ) {
if( this != &rhs ) // avoid self assignment
{
// Release the contents of this list first
clear(); // An optimization might be possible by reusing already allocated nodes
// Walk the right hand side list adding copies of the elements to this list maintaining order
for( Node<T> * position = rhs.head->next; position != rhs.tail; position = position->next ) {
append( position->data );
}
}
return *this;

}

Think like, you are adding function/s to this class code. Also write a helper function.

A string is a palindrome if its reverse is the same as the original string. For e.g. “civic” is a palindrome. The function should return bool true or false.



b) Why do we have to write two functions for the above recursive implementation ? How many functions do we have to write for the singly linked list we created in Simple Singly Linked List Example.cpp code posted on Titanium ?


In: Computer Science

We learned that share value maximization is the ultimate goal of a firm in the market...

We learned that share value maximization is the ultimate goal of a firm in the

market economy? How does this seemingly selfish goal benefit the entire society?

Please answer this question in a essay format!

In: Finance

Barking deer. Microhabitat factors associated with forage and bed sites of barking deer in Hainan Island,...

Barking deer.

Microhabitat factors associated with forage and bed sites of barking deer in Hainan Island, China were examined from 2001 to 2002. In this region woods make up 4.8% of the land, cultivated grass plot makes up 14.7%, and deciduous forests makes up 39.6%. Of the 426 sites where the deer forage, 4 were categorized as woods, 16 as cultivated grassplot, and 61 as deciduous forests. The table below summarizes these data.

Woods Cultivated Grass Deciduous Forest Other Total
4 16 67 345 426
  1. Write the hypotheses for testing if barking deer prefer to forage in certain habitats over others.

  2. What type of test can we use to answer this research question?
  3. Check if the assumptions and conditions required for this test are satisfied.
  4. Do these data provide convincing evidence that barking deer prefer to forage in certain habitats over others? Conduct an appro- priate hypothesis test to answer this research question.

In: Math

Part #1 Prove the following by using a Truth Table: x + !xy = x +...

Part #1

Prove the following by using a Truth Table:

        x + !xy = x + y

Part #2

Prove the following by using a Truth Table:

        x(!x + y) = xy

Part #3

Simplify the following Boolean expression using Karnaugh maps:

        ABC + ABC + ABC

Part #4

Simplify the following Boolean expression using Karnaugh maps:

        ABC + ABC + ABC 

Part #5

Simplify the following Boolean expression using Karnaugh maps:

        ABCD + ABCD + ABCD + ABCD

Part #6

Simplify the following Boolean expression using Karnaugh maps:

        ABCD + ABCD + ABCD + ABCD

In: Computer Science

- In details write a report using your own words and mention some references (at least...

- In details write a report using your own words and mention some references (at least 3 books) about Cloud Security Concerns, Risk Issues, and Legal Aspects. (2-3 pages)

In: Computer Science

To find the height of an overhead power line, you throw a ball straight upward. The...

To find the height of an overhead power line, you throw a ball straight upward. The ball passes the line on the way up after 0.85 s , and passes it again on the way down 1.5 s after it was tossed.

a) What is the height of the power line?

b) What is the initial speed of the ball?

In: Physics

1. Methylergonovine maleate is available in 0.2 mg tablets. The prescription is for 0.4 mg every...

1. Methylergonovine maleate is available in 0.2 mg tablets. The prescription is for 0.4 mg every 8 hours after delivery for 48 hours. How many tablets are needed for one day (24 hours)? Round your final answer to one decimal place. Type your final answer and label in the answer. Thank you!

2. An infant was born at 30 weeks weighing 2 pounds 9 oz. (1.162 kg). The baby is being fed Special Care Formula (24 calories per ounce). Based on a premature infant's cardiac needs of 130 calories/kg/day.

a. How many calories per day does this baby require?

b. How many ml of formula is required every 24 hours to provide the needed calories determined in the previous question?

c. Using the conversion factor of 1 ounce=30 ml, how many ml should be given at each feeding in order to provide the needed calories, if the infant is feed every three hours? Round your final answer to the nearest whole calorie. Type you final answer and label. Thank you!

3. The client is experiencing a postpartum hemorrhage. The physician prescribes 30 IU Oxytocin added to a 500 ml bag of Lactated Ringers to run at 150 ml/hr. Oxytocin is available 10 IU per ml.

a. How many ml of Oxytocin will be added to the bag of Lactated Ringers? Round your final answer to one decimal place with label.

b. After one hour at the prescribed rate of 150 ml/hr, how many units of Oxytocin has the client received?

c. The mother is still hemorrhaging. The primary care provider prescribes Carboprost tromethamine 350 mcg intramuscularly. The drug is available in 250 mcg per 1 ml. how much volume in ml will the nurse administer? Please round answer to one decimal place. Thank you!

4. The nurse is preparing to administer 1 mg Phytonadione Intramuscularly to a newborn. The medication on hand is 2 mg/1 ml. What is the correct volume of the injection in ml? Round your final answer to two decimal places.

5. The nurse is to give a new mother Ibuprofen 800 mg by mouth for severe uterine cramping after delivery. The pharmacy stocks Ibuprofen as 200 mg tablets. How many tablets will the nurse give? Round your final answer to one decimal place. Thank you!

In: Advanced Math

This is the question Write a function add(vals1, vals2) that takes as inputs two lists of...

This is the question

Write a function add(vals1, vals2) that takes as inputs two lists of 0 or more numbers, vals1 and vals2, and that uses recursion to construct and return a new list in which each element is the sum of the corresponding elements of vals1 and vals2. You may assume that the two lists have the same length.

For example:

>>> add([1, 2, 3], [3, 5, 8])
result: [4, 7, 11]

Note that:

  • The first element of the result is the sum of the first elements of the original lists (1 + 3 –> 4).
  • The second element of the result is the sum of the second elements of the original lists (2 + 5 –> 7).
  • The third element of the result is the sum of the third elements of the original lists (3 + 8 –> 11)

And this is why i have for the code. But i have not learned del function and im afraid i cant use it.

im only allowed to use

  • arithmetic operators: +, -, *, **, /, //, %
  • boolean operators: <, >, <=, >=, ==, !=
  • comments and docstrings
  • conditional statements: if, elif, else
  • len()
  • logical operators: and, or, not
  • list operations: indexing, slicing, skip-slicing, concatenation, construction
  • print()
  • recursion
  • string operations: indexing, slicing, concatenation, duplication
  • type()

def add(vals1,vals2):
    """return a new list in which each elements is the sum of
        the corresponding elements of val1 and vals2
        input: lists of 0 or more numbers
    """
    if (len(vals1))==0:
        return []
    else:
        x = vals1[0]+vals2[0]
        del vals1[0],vals2[0]
      
      

        return [x]+add(vals1,vals2)

In: Computer Science

Consider a multiple-choice examination with 50 questions. Each question has four possible answers. Assume that a...

Consider a multiple-choice examination with 50 questions. Each question has four possible answers. Assume that a student who has done the homework and attended lectures has a 65% chance of answering any question correctly. (Round your answers to two decimal places.)

(a) A student must answer 44 or more questions correctly to obtain a grade of A. What percentage of the students who have done their homework and attended lectures will obtain a grade of A on this multiple-choice examination? Use the normal approximation of the binomial distribution to answer this question.

(b) A student who answers 34 to 39 questions correctly will receive a grade of C. What percentage of students who have done their homework and attended lectures will obtain a grade of C on this multiple-choice examination? Use the normal approximation of the binomial distribution to answer this question.

(c) A student must answer 30 or more questions correctly to pass the examination. What percentage of the students who have done their homework and attended lectures will pass the examination? Use the normal approximation of the binomial distribution to answer this question.

(d) Assume that a student has not attended class and has not done the homework for the course. Furthermore, assume that the student will simply guess at the answer to each question. What is the probability that this student will answer 30 or more questions correctly and pass the examination? Use the normal approximation of the binomial distribution to answer this question.

In: Math

What are the most significant similarities and differences between ethical decision-making processes prescribed in the APA...

What are the most significant similarities and differences between ethical decision-making processes prescribed in the APA ethics code and those based in a Christian worldview? Explain. How might your research be influenced by these processes? Explain.


In: Psychology

Question 1: Given the infix arithmetic expression as follows: Exp = Z * ((B + C...

Question 1:

Given the infix arithmetic expression as follows:

Exp = Z * ((B + C * D) / S + F)

            Where the values of the variables are:

                        Z = 3, B = 6, C = 2, D = 5, S = 4 , F = 21

            Evaluate the expression using a stack. Shows the logical representation of the evaluation process.

..............................................................................

In: Computer Science

Morris Corporation has the following information on its balance sheets: Cash = $40, accounts receivable =...

Morris Corporation has the following information on its balance sheets: Cash = $40, accounts receivable = $30, inventories = $100, net fixed assets = $500, accounts payable = $20, accruals = $10, short-term debt (matures in less than a year) = $25, long-term debt = $200, and total common equity = $415. Its income statement reports: Sales = $820, costs of goods sold (excluding depreciation) = $450, depreciation = $50, interest expense = $20, and tax rate = 40%. Calculate the following ratios: Net profit margin , operating profit margin , basic earning power ratio and return on total assets and return on common equity

In: Finance

assume the Canadian dollar spot rate is 1.18c$/us$, the swiss spot rate is 1.29CHF/us$ and the...

assume the Canadian dollar spot rate is 1.18c$/us$, the swiss spot rate is 1.29CHF/us$ and the market cross rate is 1.11 chf/c$ a. calculate the implied cross-rate of CHF/c$ b calculate the triangular arbitrage profit, assume you have us$1000 to work with

In: Finance

Continue your observation of the 10-year period selected for Milestones One and Two and research the...

Continue your observation of the 10-year period selected for Milestones One and Two and research the government monetary policies during that time frame. This year are 2005-2015, I need actual data not definitions of the terms specified down below. Specifically, the following critical elements must be addressed:

 Examine the monetary policies in place at the start of your specific time period in relation to their effects on macroeconomic issues. For instance, consider the discount rate set by the Fed, the rates on reserves, open market operations, and so on.

 Analyze new monetary policy actions undertaken by the U.S. government throughout the time period by describing their intended effects, using macroeconomic principles to explain the actions.

 Explain the impact of the new monetary policy actions on individuals and businesses within the economy by integrating the macroeconomic data and principles.

In: Economics

1. On March 1, 20x7, E and F formed a partnership with each contributing the following...

1. On March 1, 20x7, E and F formed a partnership with each contributing the following assets:

E

F

Cash

         20,000

               50,000

Office Equipment

      100,000

               80,000

Building

                  -  

             300,000

Furniture& Fixtures

         30,000

                        -  

The building is subject to a mortgage loan of P80,000, which is to be assumed by the partnership. The partnershipagreement provides that E and F share profits and losses at 30% and 70% respectively. Assuming that thepartners agreed to bring their respective capital in proportion to their P & L ratios, and using F capital as the base.

Compute the capital account balance of F on March 1, 20x7.

Select one:

a. P350,000

b. P510,000

c. P460,000

d. P430,000

2.

On March 1, 20x7, E and F formed a partnership with each contributing the following assets:

E

F

Cash

         20,000

               50,000

Office Equipment

      100,000

               80,000

Building

                  -  

             300,000

Furniture& Fixtures

         30,000

                        -  

The building is subject to a mortgage loan of P80,000, which is to be assumed by the partnership. The partnership agreement provides that E and F share profits and losses at 30% and 70% respectively. Assuming that the partners agreed to bring their respective capital in proportion to their P & L ratios, and using F capital as the base.

How much is the additional cash to be invested by E?

Select one:

a. -0-

b. P200,000

c. P20,000

d. P100,000

3.

SS, TT, UU, and VV, partners to a law firm, shares profits at ratio of 4:3:1:1. On June 30, relevant partners’ accounts follow:

Advances (Dr)

Loans (Cr)

Capital (Cr)

SS

                     -  

       10,000

        50,000

TT

                     -  

       15,000

          80,000

UU

            22,000

                -  

          55,000

VV

            18,000

          75,000

On this day, cash of P60,000 is declared as available for distribution to partnersas profits. Who among the partners will benefit from the P60,000 cash distribution?

Select one:

a. All of the partners

b. TT and VV

c. TT, UU and VV

d. TT only

4.

Brand Constructions began operation in 20x8. Construction activities for the first year is shown below. All contract are with different customers, and any work remaining at December 31, 20x8 is expected to be completed in 20x9. Brand uses the cost-to-cost percentage of completion in accounting for its projects.

Project

Contract price

Billings to date

Collections to date

Actual costs to date

Additional cost to complete

One

560,000

360,000

       340,000

     450,000

         130,000

Two

670,000

220,000

       210,000

     126,000

         504,000

Three

520,000

500,000

       440,000

     330,000

Totals

1,750,000

1,080,000

       990,000

     906,000

         634,000

Calculate the amount of inventory recognized as a current asset in the 20x8 balance sheet.

Select one:

a. P86,000

b. P-0-

c. P24,000

d. P70,000

5.

Partnership of T, U and V and their profit and loss ratios were as follows:

Assets

P 500,000

T, loan

P    20,000

T, capital (30%)

140,000

U, capital (30%)

120,000

V, capital (40%)

180,000

Total equities

460,000

T decided to retire from the partnership and by mutual agreement, the assets were adjusted to their current fairvalue of P625,000. The partnership paid P200,000 cash for T’s equity in the partnership, exclusive of the loanwhich was repaid in full.

The capital balances of U and V, respectively, after T’s retirement from the partnership was:

Select one:

a. P146,250 and P218,750

b. P147,857 and P217,143

c. P139,286 and P205,714

d. P94,286 and P145,714

6.

On June 1, A and B pooled their assets to form a partnership, with the firm to take over their business assets and assumethe liabilities. Partners’ capitals are to be based on net assets transferred after the following adjustments:

  1. B’s inventory is to be increased by P5,000.
  2. An allowance for doubtful accounts of P2,800 and P2,500 are to be set up on the books of A and B, respectively.
  3. Accounts payable of P7,000 is to be recognized on the books of A.

The individual trial balances on June 1, before adjustments follow:

A, capital

B, capital

Assets

P   90,000

P   45,000

Liabilities

         10,000

5,000

Capital

         80,000

40,000

What is the capital balance of B after adjustments?

Select one:

a. P45,200

b. P35,500

c. P42,000

d. P42,500

In: Accounting