Questions
Problem 3 Prototype object doubleQ A doubleQ object has 2 instance variables: firstQ and secondQ arrays...

Problem 3

Prototype object doubleQ

A doubleQ object has 2 instance variables: firstQ and secondQ

arrays that together implement a queue

enqueue() instance method adds its argument to the end of this.secondQ

dequeue() instance method removes and returns the element at the front of this.firstQ

transfer() instance method removes the element from the front of this.secondQ, adds it to the end of this.firstQ

If this.secondQ is empty, does nothing

Test code is included in the file

Download this file (with fragments missing)

Hint: Use the push() and shift()

Listing

<html>

<head>

<title>Assignment 3, Problem 3</title>

<script type="text/Javascript">

function doubleQ( q1, q2 )

{

    this.firstQ = q1 || [];

    this.secondQ = q2 || [];

    this.enqueue = function( item )

                   {                  }; // Code missing

    this.dequeue = function()

                   {                  }; // Code missing

    this.toString = function()

                    { return "[" + this.firstQ + "] ["

                      + this.secondQ + "]"; };

}

function doubleQ_transfer()

{

        // Code missing

}

doubleQ.prototype.transfer = doubleQ_transfer;

var dQ = new doubleQ( [1, 2], [3, 4] );

document.write( "<p>dQ: " + dQ + "</p>" );

dQ.transfer()

document.write( "<p>After transfer: " + dQ + "</p>" );

document.write( "<p>Value dequeued: " + dQ.dequeue() + "</p>" );

document.write( "<p>After dequeue: " + dQ + "</p>" );

dQ.enqueue(5);

document.write( "<p>After enqueuing 5: " + dQ + "</p>" );

</script>

</head>

<body>

</body>

</html>

Output

dQ: [1,2] [3,4]

After transfer: [1,2,3] [4]

Value dequeued: 1

After dequeue: [2,3] [4]

After enqueuing 5: [2,3] [4,5]

In: Computer Science

Please solve in C++ only class is not templated You need to write a class called...

Please solve in C++ only

class is not templated

You need to write a class called LinkedList that implements the following List operations:

public void add(int index, Object item);
// adds an item to the list at the given index, that index may be at start, end or after or before the

// specific element

2.public void remove(int index);

// removes the item from the list that has the given index

3.public void remove(Object item);

// finds the item from list and removes that item from the list

4.public List duplicate();

// creates a duplicate of the list

// postcondition: returns a copy of the linked list

5.public List duplicateReversed();

// creates a duplicate of the list with the nodes in reverse order

// postcondition: returns a copy of the linked list with the nodes in

6.public List ReverseDisplay();

//print list in reverse order

7.public Delete_Smallest();

// Delete smallest element from linked list

8.public List Delete_duplicate();

// Delete duplicate elements from a given linked list.Retain the earliest entries.

9 Make a function that adds a linked list to itself at the end.

Input:

4 -> 2 -> 1 -> NULL

Output:

4 -> 2 -> 1 -> 4 -> 2 -> 1 -> NULL

note : code should work on Visual studio 2017 and provide screenshot of output

In: Computer Science

We are going to derive the average number of moves for quicksort using a somewhatunusual partitioning...

We are going to derive the average number of moves for quicksort using a somewhatunusual partitioning algorithm. We partition on the first element. Take it out. Look for theright most element that is smaller and place it in the first position (which is the newly openedposition on the left side). Look for the left most element that is larger and place it in the newlyopened position on the right side. Starting from there look for the right most element that issmaller and place it in the the newly opened position on the left side. Starting from there lookfor the left most element that is larger and place it in the newly opened position on the rightside. Continue in this fashion until the pointers cross. Finally, put the partition element intothe hole, which is its final position in the sorted array.(a) Assume that the partition element ends up in positionq.i. What is the probability that an element originally to the left (of positionq) went tothe right (of positionq)?ii. What is the expected number of elements originally to the left that go to the right?iii. What is the probability that an element originally to the right went to the left?iv. What is the expected number of elements originally to the right that go to the left?v. What is the total expected number of moves (for partition)?(b) Write a recurrence for the expected number of moves (for quicksort).(c) Simplify the recurrence, but do not solve it.

In: Computer Science

Problem 1. When Abe graduated from Texas A&M, he bought a diamond ring with a golden...

Problem 1. When Abe graduated from Texas A&M, he bought a diamond ring with a golden insignia to impress his high school friends. The person most impressed was his old sweetheart, Beth. They grew so fond of each other that Abe asked Beth to wear his ring. Then the quarreling began. The relationship deteriorated until, in a fit of anger, Beth enrolled as a student at University of Texas. Abe, naturally, broke off the relationship and asked for the return of his ring. Beth replied that it was a gift to her and she was not about to return it. He answered that he had only loaned it to her to wear for the duration of their friendship. Abe and Beth are now involved in a legal dispute over the ring. Beth possesses the ring and she declares that she intends to sell it. Abe threatens to sue her. If Abe wins at trial, the court will require Beth to return the ring to him. The ring is worth $1,000 to Abe. If Beth wins at trial, the court will allow her to keep the ring. She would then sell the ring for $600 to an acquaintance. (The acquaintance does not know Abe and will not resell the ring to him.) In the event of a trial, each one expects to win with probability 0.5. A trial will cost Abe $250 and it will also cost Beth $250. Abe and Beth start negotiating to reach a settlement and avoid a trial. The costs of settling out of court are nil. Assume that these numbers are common knowledge for all parties.

Abe's expected value from going to trial is:

Beth's expected value from going to trial is:

The bargaining surplus over which the two are negotiating is:

If Abe and Beth were to split the bargaining surplus evenly, what kind of exchange (ring and currency) should take place?

A) Abe should let Beth keep the ring in exchange of her giving him $200.

B) Beth should give Abe the ring in exchange of him giving her $600.

C) Beth should give Abe the ring in exchange of him giving her $400.

D) Beth should give Abe the ring in exchange of him giving her $250.

E) Abe should let Beth keep the ring in exchange of her giving him $1000.

In: Math

ROULETTE is a casino game where a numbered wheel spins and a steel ball falls into...

ROULETTE is a casino game where a numbered wheel spins and a steel ball falls into a location marked by one particular colored number. In the United States there are 18 locations colored red, 18 locations colored black and 2 locations colored green. The red and black locations are numbered 1-36 and the green locations are labeled "0" and "00" as shown in the picture to the right. The wheel therefore has 38 locations in total. Note that the odd and even values are not evenly distributed within each color.

For any particular wager a player makes, an expected profit can be calculated from: Expected profit = (Prob. of winning) x (winning payout amount) - wager

(a) One potential wager is to "bet on black" where you make a wager and if the ball lands in a black location you win an additional amount equal to the wager for a total payout equal to twice the wager. For example, if you bet $1 and win the casino gives you a $2 payout. If the ball lands on red or green you would lose your wager and the payout would be $0. What is the expected profit from making a $13 "bet on black"? (round to closest penny)

(b) To “let it ride” is to make a bet and if it wins to make the same bet with the entire payout amount. For example, if you bet $1 on black and win the casino gives you $2, you then "let it ride" by betting that $2 on black and if you win again the casino would give you $4. If the ball were to land on red or green on either spin of the wheel you would lose your wager and the final payout would be $0. What is the expected profit for betting $15 on black and if you win, "letting it ride" once? I.E., betting on black and if you win betting your winnings on black again? (keep in mind that if you lose the first bet you are done; round to closest penny)

(c) Another potential wager is to "bet on odd" which has the same payout as betting on black, but wins only when the ball lands in a location with an odd number of either color. If the ball lands on an even numbered location or a green space you lose your wager and the payout would be $0. What is the expected profit from placing two bets on a single spin - $17 on black and $19 on odd? (round to closest penny)

In: Statistics and Probability

ROULETTE is a casino game where a numbered wheel spins and a steel ball falls into...

ROULETTE is a casino game where a numbered wheel spins and a steel ball falls into a location marked by one particular colored number. In the United States there are 18 locations colored red, 18 locations colored black and 2 locations colored green. The red and black locations are numbered 1-36 and the green locations are labeled "0" and "00" as shown in the picture to the right. The wheel therefore has 38 locations in total. Note that the odd and even values are not evenly distributed within each color.

For any particular wager a player makes, an expected profit can be calculated from: Expected profit = (Prob. of winning) x (winning payout amount) - wager

(a) One potential wager is to "bet on black" where you make a wager and if the ball lands in a black location you win an additional amount equal to the wager for a total payout equal to twice the wager. For example, if you bet $1 and win the casino gives you a $2 payout. If the ball lands on red or green you would lose your wager and the payout would be $0. What is the expected profit from making a $13 "bet on black"? (round to closest penny)

(b) To “let it ride” is to make a bet and if it wins to make the same bet with the entire payout amount. For example, if you bet $1 on black and win the casino gives you $2, you then "let it ride" by betting that $2 on black and if you win again the casino would give you $4. If the ball were to land on red or green on either spin of the wheel you would lose your wager and the final payout would be $0. What is the expected profit for betting $15 on black and if you win, "letting it ride" once? I.E., betting on black and if you win betting your winnings on black again? (keep in mind that if you lose the first bet you are done; round to closest penny)

(c) Another potential wager is to "bet on odd" which has the same payout as betting on black, but wins only when the ball lands in a location with an odd number of either color. If the ball lands on an even numbered location or a green space you lose your wager and the payout would be $0. What is the expected profit from placing two bets on a single spin - $17 on black and $19 on odd? (round to closest penny)

In: Statistics and Probability

Using Java create an application that will read a tab-delimited file that displays the MLB standings...

Using Java create an application that will read a tab-delimited file that displays the MLB standings Below:

League AL East

Tampa Bay 37 20

NY Yankees 32 24

Toronto 29 27

Baltimore 23 33

Boston 22 34

League AL Central

Minnesota 35 22

Chi White Sox 34 23

Cleveland 33 24

Kansas City 23 33

Detroit 22 32

League AL West

Oakland 34 21

Houston 28 28

LA Angels 26 31

Seattle 25 31

Texas 19 37

League NL East

Atlanta 34 22

Miami 28 28

Philadelphia 28 29

NY Mets 26 31

Washington 23 34

League NL Central

Chi Cubs 32 25

St. Louis 27 26

Cincinnati 29 28

Milwaukee 27 28

Pittsburgh 18 39

League NL West

LA Dodgers 39 17

San Diego 34 22

San Francisco 28 28

Colorado 25 31

Arizona 22 34

and display expanded standings in a nicely formatted way, like so:

*****************************************

* BASEBALL ANALYZER *

*****************************************



Enter the name of the standings file:


Which standings would you like to see?

1. AL East

2. AL Central

3. AL West

4. NL East

5. NL Central

6. NL West

7. Overall

8. Exit

Enter the number of your choice: 1

Team Wins Losses Pct. Behind

-----------------------------------------------

Tampa Bay 37 20 0.649        

NY Yankees 32 24 0.571 4.5

Toronto 29 27 0.518 7.5

Baltimore 23 33 0.411 13.5

Boston 22 34 0.393 14.5

Which standings would you like to see?

1. AL East

2. AL Central

3. AL West

4. NL East

5. NL Central

6. NL West

7. Overall

8. Exit

Enter the number of your choice: 2

Team Wins Losses Pct. Behind

-----------------------------------------------

Minnesota 35 22 0.614        

Chi White Sox 34 23 0.596 1.0

Cleveland 33 24 0.579 2.0

Kansas City 23 33 0.411 11.5

Detroit 22 32 0.407 11.5

In: Computer Science

. Samples of 20 products from a production line are selected every hour. Typically, 2% of...

. Samples of 20 products from a production line are selected every hour. Typically, 2% of the products require improvement. Let X denote the number of products in the sample of 25 that require improvement. A production problem is suspected if X exceeds its mean by more than 3 standard deviations. (a) If the percentage of products that require improvement remains at 2%, what is the probability that X exceeds its mean by more than 3 standard deviations? (b) If the improvement percentage increases to 5%, what is the probability that X exceeds 1? (c) If the improvement percentage increases to 5%, what is the probability that X exceeds 1 in at least one of the next five hours of samples?

In: Statistics and Probability

4) A) In a timeshare computer system, the number of teleport requests is 0.2 per millisecond,...

4) A) In a timeshare computer system, the number of teleport requests is 0.2 per millisecond, on average, and follows a Poisson distribution. So the probability that they won't come requests for the next three milliseconds is:

B) Certain resistors are manufactured with a tolerance of ± 10%. If we consider that the real resistance is evenly distributed within this interval, the probability that a resistance with value rated at 1000 Ω have an actual resistance between 990 and 1010 Ω is:

C) The asking price for a certain item is normally distributed with an average of $ 50.00 and deviation standard $ 5.00. Buyers are willing to pay an amount that is also distributed normally with a mean of $ 45.00 and standard deviation of $ 2.50. The probability that the transaction is made is:

In: Statistics and Probability

Elly's Hotdog Emporium is famous for its chilidogs. Elly's latest sales indicate that 40% of customers...

  1. Elly's Hotdog Emporium is famous for its chilidogs. Elly's latest sales indicate that 40% of customers order their chilidogs with hot peppers. Suppose 10 customers who have ordered their chilidogs are selected at random.

Required:

a. How many customers will ask for hot peppers in the expectation?    

b. What is the probability that exactly 7 customers will ask for hot peppers?

c. What is the probability that between two and six people inclusive want hot peppers?   

d. If Elly wants to repeat this experiment tomorrow, what is the probability that at least two customers will want hot peppers. Assume that the expected number of customers who want hot pepper is unchanged.                           

In: Statistics and Probability