1

Complete the implementation of the method replace: public class SinglyLinkedList private Node head, public SinglyLinkedListo this(null) public SinglyLinkedList(Node head) [ this.head -head public Nod...

Question

Complete the implementation of the method replace: public class SinglyLinkedList private Node head, public SinglyLinkedListo this(null) public SinglyLinkedList(Node head) [ this.head -head public Nod...

Complete the implementation of the method replace: public class SinglyLinkedList private Node head, public SinglyLinkedListo

Complete the implementation of the method replace: public class SinglyLinkedList private Node head, public SinglyLinkedListo this(null) public SinglyLinkedList(Node head) [ this.head -head public Node getHeado return head public void setHead(Node head) [ head: this. head Method that creates a Node containing 'item' @param item Value to be added this.headnew Node(item, this.head) * and adds it as the first element in the list *I public void add(int item) Method that finds the node at the given index d replaces its value with the value passed as a parameter 치 public void replace(int index, int item) if (index 0) return; l/Design decision , | temp while (index» | .88 temp temp index - if (index0 &&temp null) temp.setltem(

Answers

If you have any doubts, please give me comment...

public void replace(int index, int item){

if(index<0)

return;

Node temp = head;

while(index>0 && temp!=null){

temp = temp.getNext();

index--;

}

if(index==0 && temp!=null)

temp.setItem(item);

}


Similar Solved Questions

1 answers
11. What is the importance of the FAF and FASAC to the success of the FASB?...
11. What is the importance of the FAF and FASAC to the success of the FASB? 12. The three attempts at standard setting in the private sector (CAP, APB, and FASB) have all dealt with the need for a theoretical foundation. Why were the CAP and the APB unsuccessful at this endeavor?...
1 answers
What is the correct order in the patient education process? A. Assessment, planning, implementation, documentation, evaluation...
What is the correct order in the patient education process? A. Assessment, planning, implementation, documentation, evaluation B. Planning, assessment, implementation, documentation, evaluation C. Assessment, planning implementation, evaluation, documentation D. Assessment, implementation, planning,...
1 answers
Suppose real GDP is forecasted to grow by 2.93%, the velocity of money has been stable,...
Suppose real GDP is forecasted to grow by 2.93%, the velocity of money has been stable, and the Fed announces an inflation target of 3.90%. What is the largest money growth rate the Fed could implement and still achieve its inflation target? Now suppose there is a mid-year revision of the GDP foreca...
1 answers
Exercise 7-10 First-Stage Allocations (L02) The operations vice-president of the Regal Bank of Canada, Kristin Wu,...
Exercise 7-10 First-Stage Allocations (L02) The operations vice-president of the Regal Bank of Canada, Kristin Wu, has been interested in investigating the efficiency of the bank's operations. She has been particularly concerned about the costs of handling routine transactions at the bank and wo...
1 answers
A lead ball is dropped into a lake from a diving board 6.40 m above the...
A lead ball is dropped into a lake from a diving board 6.40 m above the water. After entering the water, it sinks to the bottom with a constant velocity equal to the velocity with which it hit the water. The ball reaches the bottom 5.00 s after it is released. How deep is the lake? Review v Part ...
1 answers
Q Search this course Homework (Ch 04) S. Supply: Basic Concept Complete the following table by...
Q Search this course Homework (Ch 04) S. Supply: Basic Concept Complete the following table by selecting the term that matches each definition Definition Quantity Supplied Supply Curve Supply Schedule Law of Supply The amount of a good that sellers are willing and able to supply at a given price A t...
1 answers
What would you pay for a $125,000 debenture bond that matures in 15 years and pays...
What would you pay for a $125,000 debenture bond that matures in 15 years and pays $6,250 a year in interest if you wanted to earn a yield of: Click here to view factor tables 2%? (Round factor values to 5 decimal places, e.g. 1.25124 and final answer to O decimal places, e.g. 458,581.) Amount to pa...
1 answers
Exercise 4.25 The income statement for Cheyenne Salmon Sales, which produces smoked salmon, follows: Revenue (106,200...
Exercise 4.25 The income statement for Cheyenne Salmon Sales, which produces smoked salmon, follows: Revenue (106,200 lbs) $ 870,840 Expenses Fish $ 180,540 Smoking materials 21,240 Packaging materials 31,860 Labour (wages) 350,460 Administration 159,300 Sales commissions 10,620 Total expenses 754,0...
1 answers
Suppose you want to test the claim that the mean is less than or equal to...
Suppose you want to test the claim that the mean is less than or equal to 25.6. Given a sample size of n = 40 with sample standard deviation of 2, and a level of significance of alpha = 0.05, when would you reject the null hypothesis? Select one: a. Reject null if the test statistic is greater than ...
1 answers
Problem 7. Use the following 3 call options: K1 -50, K2 - 59, K3 - 65,...
Problem 7. Use the following 3 call options: K1 -50, K2 - 59, K3 - 65, to construct an (asymmetrical) butterfly. Draw the payoff diagram (so you won't need to know the premia)....
1 answers
It takes #7.21 xx 10^-19\ "J"# of energy to remove an electron from an Fe atom. What is the wavelength of light that can do this?
It takes #7.21 xx 10^-19\ "J"# of energy to remove an electron from an Fe atom. What is the wavelength of light that can do this?...
1 answers
NEED help. Have to be done by hand and MATLAB. please help 2.) After the conversion...
NEED help. Have to be done by hand and MATLAB. please help 2.) After the conversion above nearly reaches equilibrium, the mixture is pumped to a distillation column where form C is desired. The feed stream is 34% A, 24% B and 42% C by weight. The bottom exit stream is 10% A 20% B and 70% C, while th...
1 answers
When a Fr-223 atom with 87 protons undergoes TWO successive alpha decays, what is the daughter...
When a Fr-223 atom with 87 protons undergoes TWO successive alpha decays, what is the daughter nucleus after the second decay? Rn-222 with 86 protons Po-219 with 84 protons Th-227 with 92 protons Po-215 with 84 protons Bi-215 with 83 protons...
1 answers
Using an e-commerce platform dictates that said platform demands a payment system that accommodate the remoteness...
Using an e-commerce platform dictates that said platform demands a payment system that accommodate the remoteness of said solution. As such, a remote and non-physical payment system is needed. You need to determine the benefits and drawbacks of using said payment systems, as opposed to using a physi...
1 answers
What is matter?
What is matter?...
1 answers
A hammer of mass M is moving at speed v_0 when it strikes a nail of...
A hammer of mass M is moving at speed v_0 when it strikes a nail of negligible mass that is stuck in a wooden block. The hammer is observed to drive the nail a distance L deeper into the block. Find the work W done on the hammer by the nail. Express your answer as a function of F and L, where F is t...
1 answers
Lif X 5.3.16-T son help In a recent year, an author wrote 182 checks. Use the...
lif X 5.3.16-T son help In a recent year, an author wrote 182 checks. Use the Poisson distribution to find the probability that on a randomly selected day, he wrote at least one check The probability is (Round to three decanal places as needed)...

-- 0.009716--