Questions
Given: #include <iostream> using std::cout; template <typename T> struct Node { T data; Node *link;   ...

Given:

#include <iostream>
using std::cout;


template <typename T>
struct Node {
T data;
Node *link;
  
   Node(T data=0, Node *p = nullptr) { //Note, this constructor combines both default and parameterized constructors. You may modify the contructor to your needs
this->data = data;
       link = p;
}
};

template <typename T>
class linked_list
{
Node<T> *head,*current;
public:
//default constructor
linked_list() {
head = nullptr;//the head pointer
current = nullptr;//acts as the tail of the list
}

//destructor - IMPORTANT
~linked_list() {
       current = head;
       while( current != nullptr ) {//the loop stops when both current and head are NULL
       head = head->link;
       delete current;
       current = head;
       }
}

void addLast(int n) {// to add a node at the end of the list
if(head == nullptr){
head = new Node<T>(n);
current = head;
} else {
           if( current->link != nullptr)
               current = current->link;
current->link = new Node<T>(n);
current = current->link;//You may decide whether to keep this line or not for the function
}
}
  
void print() { // to display all nodes in the list
Node<T> *tmp = head;
while (tmp != nullptr) {
cout << tmp->data << "\n";
tmp = tmp->link;
}
}
};

int main() {
linked_list<int> a;
a.addLast(1);
a.addLast(2);

   a.print();
  
return 0;
}

2. Implement the following member methods: ▪ addFirst (T data)

// Adds a node with data at the beginning of the list ▪ pop() // Removes the first node of the list. Note: Don't forget to delete/reallocate the removed dynamic memory ▪ contains(T data) //

Returns true or false if a node contains the data exists in the list ▪ update(T oldDate, T newData) //

Updates the oldData of a node in the list with newData. ▪ size()

// Returns the number of nodes in the list ▪ remove( T data) //Removes the node that contains the data. Note, you will need to check if the node exists. Again, don't forget to delete/re-allocate the dynamic memory

3. Implement the following additional member methods ▪ insertAfter(int n, T data)

//Adds a node after the n-th node. Note, you will need to check if the n th node exists, if not, do addLast(). ▪ merge(const LinkedList &linkedlist

) //Merges this object with linkedlist object. In other words, add all nodes in linkedlist to this object.

In: Computer Science

the probability that tom buys a blue car is 90%. the probability that tom buys a...

the probability that tom buys a blue car is 90%. the probability that tom buys a car with a black interior is 15%. the probability that tom buys a car which is blue and which has a black interior is 10% . find the probability that tom buys a car which is blue or tom buys a car which has black interior.

In: Statistics and Probability

Find the probability and interpret the results. If convenient, use technology to find the probability. The...

Find the probability and interpret the results. If convenient, use technology to find the probability. The population mean annual salary for environmental compliance specialists is about $61,000. A random sample of 43 specialists is drawn from this population. What is the probability that the mean salary of the sample is less than $ 59,000? Assume σ= $6,100.

The probability that the mean salary of the sample is less than $59,000 is ____  (Round to four decimal places as needed.)

Interpret the results. Choose the correct answer below.

A . About 15.8 % of samples of 43 specialists will have a mean salary less than $59,000. This is not an unusual event.

B. Only 15.8 % of samples of 43 specialists will have a mean salary less than $59,000. This is an unusual event.

C.Only 1.58 % of samples of 43 specialists will have a mean salary less than $59,000. This is an unusual event.

D.About 1.58 % of samples of 43 specialists will have a mean salary less than $59,000. This is not an unusual event.

In: Statistics and Probability

Step 1 Find an example of probability in the media. Find an example of probability in...

Step 1

Find an example of probability in the media.

Find an example of probability in some print medium – newspaper, magazine, journal, etc.

Step 2

Write about your example and post.

Prepare your discussion posting by answering the following:

  • How was probability used in this example?
  • Was it used correctly?
  • Is there a clearer way the data could have been expressed?
  • Create a graph or chart to express the data.

Cite all sources you used to find your example.

In: Statistics and Probability

Which interpretations of probability take probability to be epistemic (subjective) and which take it to be...

Which interpretations of probability take probability to be epistemic (subjective) and which take it to be ontological (objective).

In: Statistics and Probability

A.) A binomial probability experiment is conducted with the given parameters. Compute the probability of x...

A.) A binomial probability experiment is conducted with the given parameters. Compute the probability of x successes in the n independent trials of the experiment. n=12 p=0.3 x=3
B.) A binomial probability experiment is conducted with the given parameters. Compute the probability of x successes in the n independent trials of the experiment. n=20 p= 0.05 x=12
C.) A binomial probability experiment is conducted with the given parameters. Computers the probability of x successes in the n independent trials of the experiment. n=13 p=0.45 x?4
The probability of x?4 successes is ___?

In: Statistics and Probability

find the probability for the binomial peobabilitty dostribution. according to superfreakonomics. the probability that a randomly...

find the probability for the binomial peobabilitty dostribution. according to superfreakonomics. the probability that a randomly selected patient who visits the emergency room will die within 1 year of the visit is 0.05. determine the probability that more than 3 of 30 randomly selected visitors to the ER died within 1 year. if the probability is less than 0.05 the event will be called unusual. is the event an unusual event? use the complement rule.

In: Statistics and Probability

please distinguish between probability and non probability approaches. Be detailed and elaborate

please distinguish between probability and non probability approaches. Be detailed and elaborate

In: Statistics and Probability

The probability that a bridge won't pass a wellness check is 0.09. What is the probability...

The probability that a bridge won't pass a wellness check is 0.09. What is the probability that in a sample of 12 bridges, 2 or more will not pass?

*The bridges are independent,

In: Statistics and Probability

home / study / math / statistics and probability / statistics and probability questions and answers...

home / study / math / statistics and probability / statistics and probability questions and answers / a recent study conducted by the state government attempts to determine whether the voting public ... Question: A recent study conducted by the state government attempts to determine whether the voting public ... A recent study conducted by the state government attempts to determine whether the voting public supports a further increase in cigarette taxes. The opinion poll recently sampled 1,500 voting age citizens. 1,020 of the sampled citizens were in favor of an increase in cigarette taxes. The state government would like to decide if there is enough evidence to establish whether the proportion of citizens supporting an increase in cigarette taxes is significantly greater than .66. What is the alternative hypothesis? Please provide a brief explanation.

In: Statistics and Probability